zkEVM node vs CDK validium node

zkevm-node version: v0.6.0

Files changed (116) hide show
  1. {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator.go +145 -25
  2. {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator_test.go +5 -5
  3. {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/config.go +23 -0
  4. {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/interfaces.go +1 -0
  5. {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/approve.go +2 -2
  6. {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/main.go +8 -1
  7. {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/policy.go +308 -0
  8. {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/run.go +115 -15
  9. {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/set_data_availability_protocol.go +68 -0
  10. {/home/stefan/go/src/Polygon/zkevm-node → .}/config/cardonagenesis.go +0 -109
  11. {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config.go +20 -1
  12. {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config_test.go +12 -6
  13. {/home/stefan/go/src/Polygon/zkevm-node → .}/config/default.go +7 -0
  14. {/home/stefan/go/src/Polygon/zkevm-node → .}/config/mainnetgenesis.go +0 -108
  15. {/home/stefan/go/src/Polygon/zkevm-node → .}/config/network.go +9 -15
  16. {/home/stefan/go/src/Polygon/zkevm-node → .}/config/network_test.go +5 -15
  17. {/home/stefan/go/src/Polygon/zkevm-node → .}/config/testnetgenesis.go +0 -108
  18. {/home/stefan/go/src/Polygon/zkevm-node → .}/config/types/duration.go +10 -0
  19. {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/config.go +9 -0
  20. {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/dataavailability.go +139 -0
  21. {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee.go +309 -0
  22. {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee_test.go +131 -0
  23. {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/interfaces.go +58 -0
  24. {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/pool/validium-001.sql +20 -0
  25. {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0017.sql +9 -0
  26. {/home/stefan/go/src/Polygon/zkevm-node → .}/diffgen.sh +47 -0
  27. {/home/stefan/go/src/Polygon/zkevm-node → .}/docker-compose.yml +1 -1
  28. {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile +0 -1
  29. {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile.release +15 -0
  30. {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman.go +198 -144
  31. {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go +40 -31
  32. {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/interfaces.go +7 -0
  33. {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go +26 -2
  34. {/home/stefan/go/src/Polygon/zkevm-node → .}/event/event.go +3 -0
  35. {/home/stefan/go/src/Polygon/zkevm-node → .}/.golangci.yml +3 -0
  36. {/home/stefan/go/src/Polygon/zkevm-node → .}/go.mod +9 -7
  37. {/home/stefan/go/src/Polygon/zkevm-node → .}/.goreleaser-cdk.yaml +84 -0
  38. {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/client/zkevm.go +34 -0
  39. {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go +4 -1
  40. {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go +236 -1
  41. {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm.go +36 -0
  42. {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm_test.go +1 -1
  43. {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/policy.go +61 -0
  44. {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/errors.go +2 -0
  45. {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/interfaces.go +2 -0
  46. {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/types.go +23 -2
  47. {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree.go +7 -10
  48. {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/errors.go +9 -0
  49. {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/interfaces.go +10 -0
  50. {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pgpoolstorage/policy.go +202 -0
  51. {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/policy.go +43 -0
  52. {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool.go +12 -0
  53. {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool_test.go +66 -0
  54. {/home/stefan/go/src/Polygon/zkevm-node → .}/proto/src/proto/executor/v1/executor.proto +3 -0
  55. {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go +32 -4
  56. {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/interfaces.go +1 -0
  57. {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go +2 -0
  58. {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/config.go +2 -0
  59. {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/interfaces.go +6 -2
  60. {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go +15 -104
  61. {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender_test.go +1 -1
  62. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2.go +4 -0
  63. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/convertersV2.go +1 -0
  64. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/datastream.go +6 -0
  65. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/forkid.go +2 -0
  66. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/genesis.go +5 -3
  67. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/helper.go +22 -14
  68. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go +6 -3
  69. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/datastream.go +4 -1
  70. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/forkid.go +21 -2
  71. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l2block.go +3 -3
  72. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage.go +46 -0
  73. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go +88 -6
  74. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/transaction.go +8 -8
  75. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/client.go +7 -0
  76. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/errors.go +4 -0
  77. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/runtime.go +2 -0
  78. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/test/forkid_dragonfruit/dragonfruit_test.go +2 -1
  79. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/test/forkid_independent/independent_test.go +2 -1
  80. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/trace.go +135 -40
  81. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go +21 -10
  82. {/home/stefan/go/src/Polygon/zkevm-node → .}/state/types.go +2 -0
  83. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go +139 -0
  84. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block_processor_decorator.go +34 -0
  85. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block_test.go +131 -0
  86. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches.go +5 -0
  87. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/forksids.go +3 -1
  88. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forkid.go +124 -38
  89. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forkid_test.go +147 -0
  90. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/state.go +3 -0
  91. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/zkevm_rpc.go +5 -0
  92. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/config.go +6 -0
  93. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/default_l1processors.go +6 -6
  94. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go +1 -1
  95. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go +1 -0
  96. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go +1 -0
  97. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go +55 -6
  98. {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go +3 -3
  99. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol +24 -0
  100. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/Log0.sol +23 -0
  101. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/customModExp/customModExp.go +224 -0
  102. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/Log0/Log0.go +266 -0
  103. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/triggerErrors/triggerErrors.go +1 -1
  104. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml +55 -5
  105. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/datacommittee_test.go +270 -0
  106. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/debug_calltracer_test.go +3 -0
  107. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/debug_shared.go +69 -0
  108. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/debug_test.go +55 -0
  109. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_test.go +1 -1
  110. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_vector_shared.go +2 -2
  111. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/state_test.go +1 -1
  112. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/Makefile +47 -5
  113. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/operations/manager.go +21 -1
  114. {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/batchsender/main.go +2 -2
  115. {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/state/main.go +1 -1
  116. {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/state/reprocess_cmd.go +1 -1
{/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator.go RENAMED
@@ -2,6 +2,7 @@
2
 
3
  import (
4
  "context"
 
5
  "encoding/json"
6
  "errors"
7
  "fmt"
@@ -35,6 +39,8 @@
35
 
36
  ethTxManagerOwner = "aggregator"
37
  monitoredIDFormat = "proof-from-%v-to-%v"
 
 
38
  )
39
 
40
  type finalProofMsg struct {
@@ -65,6 +71,9 @@
65
  srv *grpc.Server
66
  ctx context.Context
67
  exit context.CancelFunc
 
 
 
68
  }
69
 
70
  // New creates a new aggregator.
@@ -73,6 +82,8 @@
73
  stateInterface stateInterface,
74
  ethTxManager ethTxManager,
75
  etherman etherman,
 
 
76
  ) (Aggregator, error) {
77
  var profitabilityChecker aggregatorTxProfitabilityChecker
78
  switch cfg.TxProfitabilityCheckerType {
@@ -94,6 +105,9 @@
94
  TimeCleanupLockedProofs: cfg.CleanupLockedProofsInterval,
95
 
96
  finalProof: make(chan finalProofMsg),
 
 
 
97
  }
98
 
99
  return a, nil
@@ -182,7 +196,7 @@
182
  log.Info("Establishing stream connection with prover")
183
 
184
  // Check if prover supports the required Fork ID
185
- if !prover.SupportsForkID(a.cfg.ForkId) {
186
  err := errors.New("prover does not support required fork ID")
187
  log.Warn(FirstToUpper(err.Error()))
188
  return err
@@ -267,34 +281,139 @@
267
 
268
  log.Infof("Final proof inputs: NewLocalExitRoot [%#x], NewStateRoot [%#x]", inputs.NewLocalExitRoot, inputs.NewStateRoot)
269
 
270
- // add batch verification to be monitored
271
- sender := common.HexToAddress(a.cfg.SenderAddress)
272
- to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData(proof.BatchNumber-1, proof.BatchNumberFinal, &inputs, sender)
273
- if err != nil {
274
- log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err)
275
- a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
276
- continue
277
- }
278
- monitoredTxID := buildMonitoredTxID(proof.BatchNumber, proof.BatchNumberFinal)
279
- err = a.EthTxManager.Add(ctx, ethTxManagerOwner, monitoredTxID, sender, to, nil, data, a.cfg.GasOffset, nil)
280
- if err != nil {
281
- mTxLogger := ethtxmanager.CreateLogger(ethTxManagerOwner, monitoredTxID, sender, to)
282
- mTxLogger.Errorf("Error to add batch verification tx to eth tx manager: %v", err)
283
- a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
284
- continue
285
  }
286
 
287
- // process monitored batch verifications before starting a next cycle
288
- a.EthTxManager.ProcessPendingMonitoredTxs(ctx, ethTxManagerOwner, func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) {
289
- a.handleMonitoredTxResult(result)
290
- }, nil)
291
-
292
  a.resetVerifyProofTime()
293
  a.endProofVerification()
294
  }
295
  }
296
  }
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  func (a *Aggregator) handleFailureToAddVerifyBatchToBeMonitored(ctx context.Context, proof *state.Proof) {
299
  log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal))
300
  proof.GeneratingSince = nil
@@ -1032,9 +1151,13 @@
1032
  for _, l2blockRaw := range batchRawData.Blocks {
1033
  _, contained := l1InfoTreeData[l2blockRaw.IndexL1InfoTree]
1034
  if !contained && l2blockRaw.IndexL1InfoTree != 0 {
1035
- l1InfoTreeExitRootStorageEntry, err := a.State.GetL1InfoRootLeafByIndex(ctx, l2blockRaw.IndexL1InfoTree, nil)
1036
- if err != nil {
1037
- return nil, err
 
 
 
 
1038
  }
1039
 
1040
  // Calculate smt proof
@@ -1087,7 +1210,7 @@
1087
  OldAccInputHash: previousBatch.AccInputHash.Bytes(),
1088
  OldBatchNum: previousBatch.BatchNumber,
1089
  ChainId: a.cfg.ChainID,
1090
- ForkId: a.cfg.ForkId,
1091
  BatchL2Data: batchToVerify.BatchL2Data,
1092
  L1InfoRoot: l1InfoRoot.Bytes(),
1093
  TimestampLimit: uint64(batchToVerify.Timestamp.Unix()),
 
2
 
3
  import (
4
  "context"
5
+ "crypto/ecdsa"
6
  "encoding/json"
7
  "errors"
8
  "fmt"
 
39
 
40
  ethTxManagerOwner = "aggregator"
41
  monitoredIDFormat = "proof-from-%v-to-%v"
42
+
43
+ forkId9 = uint64(9)
44
  )
45
 
46
  type finalProofMsg struct {
 
71
  srv *grpc.Server
72
  ctx context.Context
73
  exit context.CancelFunc
74
+
75
+ AggLayerClient client.ClientInterface
76
+ sequencerPrivateKey *ecdsa.PrivateKey
77
  }
78
 
79
  // New creates a new aggregator.
 
82
  stateInterface stateInterface,
83
  ethTxManager ethTxManager,
84
  etherman etherman,
85
+ agglayerClient client.ClientInterface,
86
+ sequencerPrivateKey *ecdsa.PrivateKey,
87
  ) (Aggregator, error) {
88
  var profitabilityChecker aggregatorTxProfitabilityChecker
89
  switch cfg.TxProfitabilityCheckerType {
 
105
  TimeCleanupLockedProofs: cfg.CleanupLockedProofsInterval,
106
 
107
  finalProof: make(chan finalProofMsg),
108
+
109
+ AggLayerClient: agglayerClient,
110
+ sequencerPrivateKey: sequencerPrivateKey,
111
  }
112
 
113
  return a, nil
 
196
  log.Info("Establishing stream connection with prover")
197
 
198
  // Check if prover supports the required Fork ID
199
+ if !prover.SupportsForkID(forkId9) {
200
  err := errors.New("prover does not support required fork ID")
201
  log.Warn(FirstToUpper(err.Error()))
202
  return err
 
281
 
282
  log.Infof("Final proof inputs: NewLocalExitRoot [%#x], NewStateRoot [%#x]", inputs.NewLocalExitRoot, inputs.NewStateRoot)
283
 
284
+ switch a.cfg.SettlementBackend {
285
+ case AggLayer:
286
+ if success := a.settleWithAggLayer(ctx, proof, inputs); !success {
287
+ continue
288
+ }
289
+ default:
290
+ if success := a.settleDirect(ctx, proof, inputs); !success {
291
+ continue
292
+ }
 
 
 
 
 
 
293
  }
294
 
 
 
 
 
 
295
  a.resetVerifyProofTime()
296
  a.endProofVerification()
297
  }
298
  }
299
  }
300
 
301
+ func (a *Aggregator) settleDirect(
302
+ ctx context.Context,
303
+ proof *state.Proof,
304
+ inputs ethmanTypes.FinalProofInputs,
305
+ ) (success bool) {
306
+ // add batch verification to be monitored
307
+ sender := common.HexToAddress(a.cfg.SenderAddress)
308
+
309
+ to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData(
310
+ proof.BatchNumber-1,
311
+ proof.BatchNumberFinal,
312
+ &inputs,
313
+ sender,
314
+ )
315
+ if err != nil {
316
+ log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err)
317
+ a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
318
+
319
+ return false
320
+ }
321
+
322
+ monitoredTxID := buildMonitoredTxID(proof.BatchNumber, proof.BatchNumberFinal)
323
+ err = a.EthTxManager.Add(
324
+ ctx,
325
+ ethTxManagerOwner,
326
+ monitoredTxID,
327
+ sender,
328
+ to,
329
+ nil,
330
+ data,
331
+ a.cfg.GasOffset,
332
+ nil,
333
+ )
334
+ if err != nil {
335
+ mTxLogger := ethtxmanager.CreateLogger(ethTxManagerOwner, monitoredTxID, sender, to)
336
+ mTxLogger.Errorf("Error to add batch verification tx to eth tx manager: %v", err)
337
+ a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
338
+
339
+ return false
340
+ }
341
+
342
+ // process monitored batch verifications before starting a next cycle
343
+ a.EthTxManager.ProcessPendingMonitoredTxs(
344
+ ctx,
345
+ ethTxManagerOwner,
346
+ func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) {
347
+ a.handleMonitoredTxResult(result)
348
+ },
349
+ nil,
350
+ )
351
+
352
+ return true
353
+ }
354
+
355
+ func (a *Aggregator) settleWithAggLayer(
356
+ ctx context.Context,
357
+ proof *state.Proof,
358
+ inputs ethmanTypes.FinalProofInputs,
359
+ ) (success bool) {
360
+ proofStrNo0x := strings.TrimPrefix(inputs.FinalProof.Proof, "0x")
361
+ proofBytes := common.Hex2Bytes(proofStrNo0x)
362
+ tx := tx.Tx{
363
+ LastVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumber - 1),
364
+ NewVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumberFinal),
365
+ ZKP: tx.ZKP{
366
+ NewStateRoot: common.BytesToHash(inputs.NewStateRoot),
367
+ NewLocalExitRoot: common.BytesToHash(inputs.NewLocalExitRoot),
368
+ Proof: agglayerTypes.ArgBytes(proofBytes),
369
+ },
370
+ RollupID: a.Ethman.GetRollupId(),
371
+ }
372
+ signedTx, err := tx.Sign(a.sequencerPrivateKey)
373
+
374
+ if err != nil {
375
+ log.Errorf("failed to sign tx: %v", err)
376
+ a.handleFailureToSendToAggLayer(ctx, proof)
377
+
378
+ return false
379
+ }
380
+
381
+ log.Debug("final proof signedTx: ", signedTx.Tx.ZKP.Proof.Hex())
382
+ txHash, err := a.AggLayerClient.SendTx(*signedTx)
383
+ if err != nil {
384
+ log.Errorf("failed to send tx to the interop: %v", err)
385
+ a.handleFailureToSendToAggLayer(ctx, proof)
386
+
387
+ return false
388
+ }
389
+
390
+ log.Infof("tx %s sent to agglayer, waiting to be mined", txHash.Hex())
391
+ log.Debugf("Timeout set to %f seconds", a.cfg.AggLayerTxTimeout.Duration.Seconds())
392
+ waitCtx, cancelFunc := context.WithDeadline(ctx, time.Now().Add(a.cfg.AggLayerTxTimeout.Duration))
393
+ defer cancelFunc()
394
+ if err := a.AggLayerClient.WaitTxToBeMined(txHash, waitCtx); err != nil {
395
+ log.Errorf("interop didn't mine the tx: %v", err)
396
+ a.handleFailureToSendToAggLayer(ctx, proof)
397
+
398
+ return false
399
+ }
400
+
401
+ // TODO: wait for synchronizer to catch up
402
+ return true
403
+ }
404
+
405
+ func (a *Aggregator) handleFailureToSendToAggLayer(ctx context.Context, proof *state.Proof) {
406
+ log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal))
407
+ proof.GeneratingSince = nil
408
+
409
+ err := a.State.UpdateGeneratedProof(ctx, proof, nil)
410
+ if err != nil {
411
+ log.Errorf("Failed updating proof state (false): %v", err)
412
+ }
413
+
414
+ a.endProofVerification()
415
+ }
416
+
417
  func (a *Aggregator) handleFailureToAddVerifyBatchToBeMonitored(ctx context.Context, proof *state.Proof) {
418
  log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal))
419
  proof.GeneratingSince = nil
 
1151
  for _, l2blockRaw := range batchRawData.Blocks {
1152
  _, contained := l1InfoTreeData[l2blockRaw.IndexL1InfoTree]
1153
  if !contained && l2blockRaw.IndexL1InfoTree != 0 {
1154
+ l1InfoTreeExitRootStorageEntry := state.L1InfoTreeExitRootStorageEntry{}
1155
+ l1InfoTreeExitRootStorageEntry.Timestamp = time.Unix(0, 0)
1156
+ if l2blockRaw.IndexL1InfoTree <= leaves[len(leaves)-1].L1InfoTreeIndex {
1157
+ l1InfoTreeExitRootStorageEntry, err = a.State.GetL1InfoRootLeafByIndex(ctx, l2blockRaw.IndexL1InfoTree, nil)
1158
+ if err != nil {
1159
+ return nil, err
1160
+ }
1161
  }
1162
 
1163
  // Calculate smt proof
 
1210
  OldAccInputHash: previousBatch.AccInputHash.Bytes(),
1211
  OldBatchNum: previousBatch.BatchNumber,
1212
  ChainId: a.cfg.ChainID,
1213
+ ForkId: forkId9,
1214
  BatchL2Data: batchToVerify.BatchL2Data,
1215
  L1InfoRoot: l1InfoRoot.Bytes(),
1216
  TimestampLimit: uint64(batchToVerify.Timestamp.Unix()),
{/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator_test.go RENAMED
@@ -191,7 +191,7 @@
191
  stateMock := mocks.NewStateMock(t)
192
  ethTxManager := mocks.NewEthTxManager(t)
193
  etherman := mocks.NewEtherman(t)
194
- a, err := New(cfg, stateMock, ethTxManager, etherman)
195
  require.NoError(err)
196
  a.ctx, a.exit = context.WithCancel(context.Background())
197
  m := mox{
@@ -686,7 +686,7 @@
686
  ethTxManager := mocks.NewEthTxManager(t)
687
  etherman := mocks.NewEtherman(t)
688
  proverMock := mocks.NewProverMock(t)
689
- a, err := New(cfg, stateMock, ethTxManager, etherman)
690
  require.NoError(err)
691
  aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
692
  a.ctx, a.exit = context.WithCancel(aggregatorCtx)
@@ -1029,7 +1029,7 @@
1029
  ethTxManager := mocks.NewEthTxManager(t)
1030
  etherman := mocks.NewEtherman(t)
1031
  proverMock := mocks.NewProverMock(t)
1032
- a, err := New(cfg, stateMock, ethTxManager, etherman)
1033
  require.NoError(err)
1034
  aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
1035
  a.ctx, a.exit = context.WithCancel(aggregatorCtx)
@@ -1306,7 +1306,7 @@
1306
  ethTxManager := mocks.NewEthTxManager(t)
1307
  etherman := mocks.NewEtherman(t)
1308
  proverMock := mocks.NewProverMock(t)
1309
- a, err := New(cfg, stateMock, ethTxManager, etherman)
1310
  require.NoError(err)
1311
  aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
1312
  a.ctx, a.exit = context.WithCancel(aggregatorCtx)
@@ -1436,7 +1436,7 @@
1436
  ethTxManager := mocks.NewEthTxManager(t)
1437
  etherman := mocks.NewEtherman(t)
1438
  proverMock := mocks.NewProverMock(t)
1439
- a, err := New(cfg, stateMock, ethTxManager, etherman)
1440
  require.NoError(err)
1441
  aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
1442
  a.ctx, a.exit = context.WithCancel(aggregatorCtx)
 
191
  stateMock := mocks.NewStateMock(t)
192
  ethTxManager := mocks.NewEthTxManager(t)
193
  etherman := mocks.NewEtherman(t)
194
+ a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
195
  require.NoError(err)
196
  a.ctx, a.exit = context.WithCancel(context.Background())
197
  m := mox{
 
686
  ethTxManager := mocks.NewEthTxManager(t)
687
  etherman := mocks.NewEtherman(t)
688
  proverMock := mocks.NewProverMock(t)
689
+ a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
690
  require.NoError(err)
691
  aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
692
  a.ctx, a.exit = context.WithCancel(aggregatorCtx)
 
1029
  ethTxManager := mocks.NewEthTxManager(t)
1030
  etherman := mocks.NewEtherman(t)
1031
  proverMock := mocks.NewProverMock(t)
1032
+ a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
1033
  require.NoError(err)
1034
  aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
1035
  a.ctx, a.exit = context.WithCancel(aggregatorCtx)
 
1306
  ethTxManager := mocks.NewEthTxManager(t)
1307
  etherman := mocks.NewEtherman(t)
1308
  proverMock := mocks.NewProverMock(t)
1309
+ a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
1310
  require.NoError(err)
1311
  aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
1312
  a.ctx, a.exit = context.WithCancel(aggregatorCtx)
 
1436
  ethTxManager := mocks.NewEthTxManager(t)
1437
  etherman := mocks.NewEtherman(t)
1438
  proverMock := mocks.NewProverMock(t)
1439
+ a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
1440
  require.NoError(err)
1441
  aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
1442
  a.ctx, a.exit = context.WithCancel(aggregatorCtx)
{/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/config.go RENAMED
@@ -8,6 +8,17 @@
8
  "github.com/0xPolygonHermez/zkevm-node/encoding"
9
  )
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  // TokenAmountWithDecimals is a wrapper type that parses token amount with decimals to big int
12
  type TokenAmountWithDecimals struct {
13
  *big.Int `validate:"required"`
@@ -89,6 +100,18 @@
89
  // UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog
90
  UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"`
91
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  // BatchProofL1BlockConfirmations is number of L1 blocks to consider we can generate the proof for a virtual batch
93
  BatchProofL1BlockConfirmations uint64 `mapstructure:"BatchProofL1BlockConfirmations"`
94
  }
 
8
  "github.com/0xPolygonHermez/zkevm-node/encoding"
9
  )
10
 
11
+ // SettlementBackend is the type of the settlement backend
12
+ type SettlementBackend string
13
+
14
+ const (
15
+ // AggLayer settlement backend
16
+ AggLayer SettlementBackend = "agglayer"
17
+
18
+ // L1 settlement backend
19
+ L1 SettlementBackend = "l1"
20
+ )
21
+
22
  // TokenAmountWithDecimals is a wrapper type that parses token amount with decimals to big int
23
  type TokenAmountWithDecimals struct {
24
  *big.Int `validate:"required"`
 
100
  // UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog
101
  UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"`
102
 
103
+ // SettlementBackend configuration defines how a final ZKP should be settled. Directly to L1 or over the Beethoven service.
104
+ SettlementBackend SettlementBackend `mapstructure:"SettlementBackend"`
105
+
106
+ // AggLayerTxTimeout is the interval time to wait for a tx to be mined from the agglayer
107
+ AggLayerTxTimeout types.Duration `mapstructure:"AggLayerTxTimeout"`
108
+
109
+ // AggLayerURL url of the agglayer service
110
+ AggLayerURL string `mapstructure:"AggLayerURL"`
111
+
112
+ // SequencerPrivateKey Private key of the trusted sequencer
113
+ SequencerPrivateKey types.KeystoreFileConfig `mapstructure:"SequencerPrivateKey"`
114
+
115
  // BatchProofL1BlockConfirmations is number of L1 blocks to consider we can generate the proof for a virtual batch
116
  BatchProofL1BlockConfirmations uint64 `mapstructure:"BatchProofL1BlockConfirmations"`
117
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/interfaces.go RENAMED
@@ -38,6 +38,7 @@
38
 
39
  // etherman contains the methods required to interact with ethereum
40
  type etherman interface {
 
41
  GetLatestVerifiedBatchNum() (uint64, error)
42
  BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error)
43
  GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
 
38
 
39
  // etherman contains the methods required to interact with ethereum
40
  type etherman interface {
41
+ GetRollupId() uint32
42
  GetLatestVerifiedBatchNum() (uint64, error)
43
  BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error)
44
  GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
{/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/approve.go RENAMED
@@ -51,14 +51,14 @@
51
  setupLog(c.Log)
52
 
53
  // Check if it is already registered
54
- etherman, err := newEtherman(*c)
55
  if err != nil {
56
  log.Fatal(err)
57
  return err
58
  }
59
 
60
  // load auth from keystore file
61
- auth, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword)
62
  if err != nil {
63
  log.Fatal(err)
64
  return err
 
51
  setupLog(c.Log)
52
 
53
  // Check if it is already registered
54
+ etherman, err := newEtherman(*c, nil)
55
  if err != nil {
56
  log.Fatal(err)
57
  return err
58
  }
59
 
60
  // load auth from keystore file
61
+ auth, _, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword)
62
  if err != nil {
63
  log.Fatal(err)
64
  return err
{/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/main.go RENAMED
@@ -47,7 +47,7 @@
47
  networkFlag = cli.StringFlag{
48
  Name: config.FlagNetwork,
49
  Aliases: []string{"net"},
50
- Usage: "Load default network configuration. Supported values: [`mainnet`, `testnet`, `cardona`, `custom`]",
51
  Required: true,
52
  }
53
  customNetworkFlag = cli.StringFlag{
@@ -186,6 +186,13 @@
186
  Action: restore,
187
  Flags: restoreFlags,
188
  },
 
 
 
 
 
 
 
189
  }
190
 
191
  err := app.Run(os.Args)
 
47
  networkFlag = cli.StringFlag{
48
  Name: config.FlagNetwork,
49
  Aliases: []string{"net"},
50
+ Usage: "Load default network configuration. Supported values: [`custom`]",
51
  Required: true,
52
  }
53
  customNetworkFlag = cli.StringFlag{
 
186
  Action: restore,
187
  Flags: restoreFlags,
188
  },
189
+ {
190
+ Name: "set-data-availability-protocol",
191
+ Aliases: []string{"set-dap"},
192
+ Usage: "Sets the new data availability protocol",
193
+ Action: setDataAvailabilityProtocol,
194
+ Flags: setDataAvailabilityProtocolFlags,
195
+ },
196
  }
197
 
198
  err := app.Run(os.Args)
{/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/policy.go RENAMED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package main
2
+
3
+ import (
4
+ "context"
5
+ "encoding/csv"
6
+ "errors"
7
+ "fmt"
8
+ "os"
9
+ "strings"
10
+
11
+ "github.com/0xPolygonHermez/zkevm-node/config"
12
+ "github.com/0xPolygonHermez/zkevm-node/pool"
13
+ "github.com/0xPolygonHermez/zkevm-node/pool/pgpoolstorage"
14
+ "github.com/ethereum/go-ethereum/common"
15
+ "github.com/urfave/cli/v2"
16
+ )
17
+
18
+ var (
19
+ policyFlag = cli.StringFlag{
20
+ Name: "policy",
21
+ Aliases: []string{"p"},
22
+ Usage: "Name of policy to operate on",
23
+ Required: false,
24
+ }
25
+ csvFlag = cli.StringFlag{
26
+ Name: "csv",
27
+ Usage: "CSV file with addresses",
28
+ Required: false,
29
+ }
30
+ allowFlag = cli.BoolFlag{
31
+ Name: "allow",
32
+ Usage: "Update policy to 'allow' addresses on list",
33
+ Required: false,
34
+ }
35
+ denyFlag = cli.BoolFlag{
36
+ Name: "deny",
37
+ Usage: "Update policy to 'deny' addresses on list",
38
+ Required: false,
39
+ }
40
+ noHeaderFlag = cli.BoolFlag{
41
+ Name: "no-header",
42
+ Value: false,
43
+ Required: false,
44
+ }
45
+
46
+ policyActionFlags = []cli.Flag{&policyFlag}
47
+ )
48
+
49
+ var policyCommands = cli.Command{
50
+ Name: "policy",
51
+ Usage: "View, update, and apply policies",
52
+ Action: describe,
53
+ Flags: []cli.Flag{&configFileFlag},
54
+ Subcommands: []*cli.Command{
55
+ {
56
+ Name: "add",
57
+ Usage: "Add address(es) to a policy exclusion list",
58
+ Action: addAcl,
59
+ Flags: append(policyActionFlags, &csvFlag),
60
+ }, {
61
+ Name: "clear",
62
+ Usage: "Clear the addresses listed as exceptions to a policy",
63
+ Action: clearAcl,
64
+ Flags: policyActionFlags,
65
+ }, {
66
+ Name: "describe",
67
+ Usage: "Describe the default actions for the policies",
68
+ Action: describe,
69
+ Flags: append(policyActionFlags, &noHeaderFlag),
70
+ }, {
71
+ Name: "remove",
72
+ Usage: "Remove address(es) from a policy exclusion list",
73
+ Action: removeAcl,
74
+ Flags: append(policyActionFlags, &csvFlag),
75
+ }, {
76
+ Name: "update",
77
+ Usage: "Update the default action for a policy",
78
+ Action: updatePolicy,
79
+ Flags: append(policyActionFlags, &allowFlag, &denyFlag),
80
+ },
81
+ },
82
+ }
83
+
84
+ func updatePolicy(cli *cli.Context) error {
85
+ _, db, err := configAndStorage(cli)
86
+ if err != nil {
87
+ return err
88
+ }
89
+ policy, err := resolvePolicy(cli)
90
+ if err != nil {
91
+ return err
92
+ }
93
+
94
+ allow := cli.Bool(allowFlag.Name)
95
+ deny := cli.Bool(denyFlag.Name)
96
+
97
+ // exactly one must be set
98
+ if (allow && deny) || (!allow && !deny) {
99
+ return errors.New("supply one policy action [--allow or --deny]")
100
+ }
101
+
102
+ var setting bool
103
+ if allow {
104
+ setting = true
105
+ } else if deny {
106
+ setting = false
107
+ }
108
+
109
+ err = db.UpdatePolicy(context.Background(), policy, setting)
110
+ if err != nil {
111
+ return err
112
+ }
113
+ return nil
114
+ }
115
+
116
+ func addAcl(cli *cli.Context) error {
117
+ _, db, err := configAndStorage(cli)
118
+ if err != nil {
119
+ return err
120
+ }
121
+ policy, addresses, err := requirePolicyAndAddresses(cli)
122
+ if err != nil {
123
+ return err
124
+ }
125
+ err = db.AddAddressesToPolicy(context.Background(), policy, addresses)
126
+ if err != nil {
127
+ return err
128
+ }
129
+ return nil
130
+ }
131
+
132
+ func removeAcl(cli *cli.Context) error {
133
+ _, db, err := configAndStorage(cli)
134
+ if err != nil {
135
+ return err
136
+ }
137
+ policy, addresses, err := requirePolicyAndAddresses(cli)
138
+ if err != nil {
139
+ return err
140
+ }
141
+ err = db.RemoveAddressesFromPolicy(context.Background(), policy, addresses)
142
+ if err != nil {
143
+ return err
144
+ }
145
+ return nil
146
+ }
147
+
148
+ func clearAcl(cli *cli.Context) error {
149
+ _, db, err := configAndStorage(cli)
150
+ if err != nil {
151
+ return err
152
+ }
153
+ policy, err := resolvePolicy(cli)
154
+ if err != nil {
155
+ return err
156
+ }
157
+ err = db.ClearPolicy(context.Background(), policy)
158
+ if err != nil {
159
+ return err
160
+ }
161
+ return nil
162
+ }
163
+
164
+ func describe(cli *cli.Context) error {
165
+ showHeader := !cli.Bool(noHeaderFlag.Name)
166
+ if cli.IsSet(policyFlag.Name) {
167
+ return describePolicy(cli, showHeader)
168
+ }
169
+ return describePolicies(cli, showHeader)
170
+ }
171
+
172
+ func describePolicy(cli *cli.Context, showHeader bool) error {
173
+ _, db, err := configAndStorage(cli)
174
+ if err != nil {
175
+ return err
176
+ }
177
+
178
+ policyName, err := resolvePolicy(cli)
179
+ if err != nil {
180
+ return err
181
+ }
182
+
183
+ if showHeader {
184
+ policy, err := db.DescribePolicy(context.Background(), policyName)
185
+ if err != nil {
186
+ return err
187
+ }
188
+ fmt.Printf("%s: %s\n", "Policy", policy.Name)
189
+ fmt.Printf("%s: %s\n", "Action", policy.Desc())
190
+ }
191
+ query, err := resolveAddresses(cli, false)
192
+ if err != nil {
193
+ return nil
194
+ }
195
+ list, err := db.ListAcl(context.Background(), policyName, query)
196
+ if err != nil {
197
+ return err
198
+ }
199
+
200
+ if showHeader {
201
+ fmt.Println("Addresses:")
202
+ }
203
+ for _, address := range list {
204
+ fmt.Println(address.Hex())
205
+ }
206
+ return nil
207
+ }
208
+
209
+ func describePolicies(cli *cli.Context, showHeader bool) error {
210
+ _, db, err := configAndStorage(cli)
211
+ if err != nil {
212
+ return err
213
+ }
214
+ list, err := db.DescribePolicies(context.Background())
215
+ if err != nil {
216
+ return err
217
+ }
218
+
219
+ if showHeader {
220
+ fmt.Printf("%7s: %s\n", "Policy", "Action")
221
+ }
222
+ for _, p := range list {
223
+ fmt.Printf("%7s: %s\n", p.Name, p.Desc())
224
+ }
225
+
226
+ return nil
227
+ }
228
+
229
+ func configAndStorage(cli *cli.Context) (*config.Config, *pgpoolstorage.PostgresPoolStorage, error) {
230
+ c, err := config.Load(cli, false)
231
+ if err != nil {
232
+ return nil, nil, err
233
+ }
234
+ setupLog(c.Log)
235
+
236
+ db, err := pgpoolstorage.NewPostgresPoolStorage(c.Pool.DB)
237
+ if err != nil {
238
+ return nil, nil, err
239
+ }
240
+ return c, db, nil
241
+ }
242
+
243
+ func requirePolicyAndAddresses(cli *cli.Context) (pool.PolicyName, []common.Address, error) {
244
+ policy, err := resolvePolicy(cli)
245
+ if err != nil {
246
+ return "", nil, err
247
+ }
248
+ addresses, err := resolveAddresses(cli, true)
249
+ if err != nil {
250
+ return "", nil, err
251
+ }
252
+ return policy, addresses, nil
253
+ }
254
+
255
+ func resolvePolicy(cli *cli.Context) (pool.PolicyName, error) {
256
+ policy := cli.String(policyFlag.Name)
257
+ if policy == "" {
258
+ return "", nil
259
+ }
260
+ if !pool.IsPolicy(policy) {
261
+ return "", fmt.Errorf("invalid policy name: %s", policy)
262
+ }
263
+ return pool.PolicyName(policy), nil
264
+ }
265
+
266
+ func resolveAddresses(cli *cli.Context, failIfEmpty bool) ([]common.Address, error) {
267
+ var set = make(map[common.Address]struct{})
268
+ if cli.IsSet("csv") {
269
+ file := cli.String(csvFlag.Name)
270
+ fd, err := os.Open(file)
271
+ if err != nil {
272
+ return nil, err
273
+ }
274
+ defer func(fd *os.File) {
275
+ _ = fd.Close()
276
+ }(fd)
277
+
278
+ fileReader := csv.NewReader(fd)
279
+ records, err := fileReader.ReadAll()
280
+
281
+ if err != nil {
282
+ return nil, err
283
+ }
284
+ for _, row := range records {
285
+ for _, cell := range row {
286
+ hex := strings.TrimSpace(cell)
287
+ set[common.HexToAddress(hex)] = struct{}{}
288
+ }
289
+ }
290
+ }
291
+
292
+ for _, a := range cli.Args().Slice() {
293
+ a = strings.TrimSpace(a)
294
+ a = strings.Trim(a, ",|")
295
+ if !strings.HasPrefix(a, "0x") {
296
+ a = "0x" + a
297
+ }
298
+ set[common.HexToAddress(a)] = struct{}{}
299
+ }
300
+ var ret []common.Address
301
+ for a := range set {
302
+ ret = append(ret, a)
303
+ }
304
+ if failIfEmpty && len(ret) == 0 {
305
+ return nil, errors.New("no addresses given")
306
+ }
307
+ return ret, nil
308
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/run.go RENAMED
@@ -2,6 +2,7 @@
2
 
3
  import (
4
  "context"
 
5
  "errors"
6
  "fmt"
7
  "net"
@@ -107,19 +112,27 @@
107
  log.Fatal(err)
108
  }
109
 
110
- etherman, err := newEtherman(*c)
 
111
  if err != nil {
112
  log.Fatal(err)
113
  }
114
-
115
- // READ CHAIN ID FROM POE SC
116
- l2ChainID, err := etherman.GetL2ChainID()
117
  if err != nil {
118
  log.Fatal(err)
119
  }
120
 
 
 
 
 
121
  st, currentForkID := newState(cliCtx.Context, c, etherman, l2ChainID, stateSqlDB, eventLog, needsExecutor, needsStateTree, false)
122
 
 
 
 
 
 
123
  c.Aggregator.ChainID = l2ChainID
124
  c.Sequencer.StreamServer.ChainID = l2ChainID
125
  log.Infof("Chain ID read from POE SC = %v", l2ChainID)
@@ -276,8 +289,79 @@
276
  }
277
  }
278
 
279
- func newEtherman(c config.Config) (*etherman.Client, error) {
280
- return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  }
282
 
283
  func runSynchronizer(cfg config.Config, etherman *etherman.Client, ethTxManagerStorage *ethtxmanager.PostgresStorage, st *state.State, pool *pool.Pool, eventLog *event.EventLog) {
@@ -296,12 +380,11 @@
296
  log.Info("trustedSequencerURL ", trustedSequencerURL)
297
  }
298
  zkEVMClient := client.NewClient(trustedSequencerURL)
299
-
300
  etherManForL1 := []syncinterfaces.EthermanFullInterface{}
301
  // If synchronizer are using sequential mode, we only need one etherman client
302
  if cfg.Synchronizer.L1SynchronizationMode == synchronizer.ParallelMode {
303
  for i := 0; i < int(cfg.Synchronizer.L1ParallelSynchronization.MaxClients+1); i++ {
304
- eth, err := newEtherman(cfg)
305
  if err != nil {
306
  log.Fatal(err)
307
  }
@@ -404,12 +487,12 @@
404
  }
405
 
406
  func createSequenceSender(cfg config.Config, pool *pool.Pool, etmStorage *ethtxmanager.PostgresStorage, st *state.State, eventLog *event.EventLog) *sequencesender.SequenceSender {
407
- etherman, err := newEtherman(cfg)
408
  if err != nil {
409
  log.Fatal(err)
410
  }
411
 
412
- auth, err := etherman.LoadAuthFromKeyStore(cfg.SequenceSender.PrivateKey.Path, cfg.SequenceSender.PrivateKey.Password)
413
  if err != nil {
414
  log.Fatal(err)
415
  }
@@ -419,7 +502,12 @@
419
 
420
  ethTxManager := ethtxmanager.New(cfg.EthTxManager, etherman, etmStorage, st)
421
 
422
- seqSender, err := sequencesender.New(cfg.SequenceSender, st, etherman, ethTxManager, eventLog)
 
 
 
 
 
423
  if err != nil {
424
  log.Fatal(err)
425
  }
@@ -428,7 +516,23 @@
428
  }
429
 
430
  func runAggregator(ctx context.Context, c aggregator.Config, etherman *etherman.Client, ethTxManager *ethtxmanager.Client, st *state.State) {
431
- agg, err := aggregator.New(c, st, ethTxManager, etherman)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  if err != nil {
433
  log.Fatal(err)
434
  }
@@ -498,7 +602,7 @@
498
  }
499
  log.Infof("Starting L1InfoRoot: %v", l1inforoot.String())
500
 
501
- forkIDIntervals, err := forkIDIntervals(ctx, st, etherman, c.NetworkConfig.Genesis.BlockNumber)
502
  if err != nil {
503
  log.Fatal("error getting forkIDs. Error: ", err)
504
  }
@@ -521,13 +625,13 @@
521
  }
522
 
523
  func createEthTxManager(cfg config.Config, etmStorage *ethtxmanager.PostgresStorage, st *state.State) *ethtxmanager.Client {
524
- etherman, err := newEtherman(cfg)
525
  if err != nil {
526
  log.Fatal(err)
527
  }
528
 
529
  for _, privateKey := range cfg.EthTxManager.PrivateKeys {
530
- _, err := etherman.LoadAuthFromKeyStore(privateKey.Path, privateKey.Password)
531
  if err != nil {
532
  log.Fatal(err)
533
  }
 
2
 
3
  import (
4
  "context"
5
+ "crypto/ecdsa"
6
  "errors"
7
  "fmt"
8
  "net"
 
112
  log.Fatal(err)
113
  }
114
 
115
+ // READ CHAIN ID FROM POE SC
116
+ tmpEthMan, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil)
117
  if err != nil {
118
  log.Fatal(err)
119
  }
120
+ l2ChainID, err := tmpEthMan.GetL2ChainID()
 
 
121
  if err != nil {
122
  log.Fatal(err)
123
  }
124
 
125
+ etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil)
126
+ if err != nil {
127
+ log.Fatal(err)
128
+ }
129
  st, currentForkID := newState(cliCtx.Context, c, etherman, l2ChainID, stateSqlDB, eventLog, needsExecutor, needsStateTree, false)
130
 
131
+ etherman, err = newEtherman(*c, st)
132
+ if err != nil {
133
+ log.Fatal(err)
134
+ }
135
+
136
  c.Aggregator.ChainID = l2ChainID
137
  c.Sequencer.StreamServer.ChainID = l2ChainID
138
  log.Infof("Chain ID read from POE SC = %v", l2ChainID)
 
289
  }
290
  }
291
 
292
+ func newEtherman(c config.Config, st *state.State) (*etherman.Client, error) {
293
+ ethman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil)
294
+ if err != nil {
295
+ return nil, err
296
+ }
297
+ da, err := newDataAvailability(c, st, ethman, false)
298
+ if err != nil {
299
+ return nil, err
300
+ }
301
+ return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, da)
302
+ }
303
+
304
+ func newDataAvailability(c config.Config, st *state.State, etherman *etherman.Client, isSequenceSender bool) (*dataavailability.DataAvailability, error) {
305
+ var (
306
+ trustedSequencerURL string
307
+ err error
308
+ )
309
+ if !c.IsTrustedSequencer {
310
+ if c.Synchronizer.TrustedSequencerURL != "" {
311
+ trustedSequencerURL = c.Synchronizer.TrustedSequencerURL
312
+ } else {
313
+ log.Debug("getting trusted sequencer URL from smc")
314
+ trustedSequencerURL, err = etherman.GetTrustedSequencerURL()
315
+ if err != nil {
316
+ return nil, fmt.Errorf("error getting trusted sequencer URI. Error: %v", err)
317
+ }
318
+ }
319
+ log.Debug("trustedSequencerURL ", trustedSequencerURL)
320
+ }
321
+ zkEVMClient := client.NewClient(trustedSequencerURL)
322
+
323
+ // Backend specific config
324
+ daProtocolName, err := etherman.GetDAProtocolName()
325
+ if err != nil {
326
+ return nil, fmt.Errorf("error getting data availability protocol name: %v", err)
327
+ }
328
+ var daBackend dataavailability.DABackender
329
+ switch daProtocolName {
330
+ case string(dataavailability.DataAvailabilityCommittee):
331
+ var (
332
+ pk *ecdsa.PrivateKey
333
+ err error
334
+ )
335
+ if isSequenceSender {
336
+ _, pk, err = etherman.LoadAuthFromKeyStore(c.SequenceSender.PrivateKey.Path, c.SequenceSender.PrivateKey.Password)
337
+ if err != nil {
338
+ return nil, err
339
+ }
340
+ }
341
+ dacAddr, err := etherman.GetDAProtocolAddr()
342
+ if err != nil {
343
+ return nil, fmt.Errorf("error getting trusted sequencer URI. Error: %v", err)
344
+ }
345
+
346
+ daBackend, err = datacommittee.New(
347
+ c.Etherman.URL,
348
+ dacAddr,
349
+ pk,
350
+ dataCommitteeClient.NewFactory(),
351
+ )
352
+ if err != nil {
353
+ return nil, err
354
+ }
355
+ default:
356
+ return nil, fmt.Errorf("unexpected / unsupported DA protocol: %s", daProtocolName)
357
+ }
358
+
359
+ return dataavailability.New(
360
+ c.IsTrustedSequencer,
361
+ daBackend,
362
+ st,
363
+ zkEVMClient,
364
+ )
365
  }
366
 
367
  func runSynchronizer(cfg config.Config, etherman *etherman.Client, ethTxManagerStorage *ethtxmanager.PostgresStorage, st *state.State, pool *pool.Pool, eventLog *event.EventLog) {
 
380
  log.Info("trustedSequencerURL ", trustedSequencerURL)
381
  }
382
  zkEVMClient := client.NewClient(trustedSequencerURL)
 
383
  etherManForL1 := []syncinterfaces.EthermanFullInterface{}
384
  // If synchronizer are using sequential mode, we only need one etherman client
385
  if cfg.Synchronizer.L1SynchronizationMode == synchronizer.ParallelMode {
386
  for i := 0; i < int(cfg.Synchronizer.L1ParallelSynchronization.MaxClients+1); i++ {
387
+ eth, err := newEtherman(cfg, st)
388
  if err != nil {
389
  log.Fatal(err)
390
  }
 
487
  }
488
 
489
  func createSequenceSender(cfg config.Config, pool *pool.Pool, etmStorage *ethtxmanager.PostgresStorage, st *state.State, eventLog *event.EventLog) *sequencesender.SequenceSender {
490
+ etherman, err := newEtherman(cfg, st)
491
  if err != nil {
492
  log.Fatal(err)
493
  }
494
 
495
+ auth, _, err := etherman.LoadAuthFromKeyStore(cfg.SequenceSender.PrivateKey.Path, cfg.SequenceSender.PrivateKey.Password)
496
  if err != nil {
497
  log.Fatal(err)
498
  }
 
502
 
503
  ethTxManager := ethtxmanager.New(cfg.EthTxManager, etherman, etmStorage, st)
504
 
505
+ da, err := newDataAvailability(cfg, st, etherman, true)
506
+ if err != nil {
507
+ log.Fatal(err)
508
+ }
509
+
510
+ seqSender, err := sequencesender.New(cfg.SequenceSender, st, etherman, ethTxManager, eventLog, da)
511
  if err != nil {
512
  log.Fatal(err)
513
  }
 
516
  }
517
 
518
  func runAggregator(ctx context.Context, c aggregator.Config, etherman *etherman.Client, ethTxManager *ethtxmanager.Client, st *state.State) {
519
+ var (
520
+ aggCli *agglayerClient.Client
521
+ pk *ecdsa.PrivateKey
522
+ err error
523
+ )
524
+
525
+ if c.SettlementBackend == aggregator.AggLayer {
526
+ aggCli = agglayerClient.New(c.AggLayerURL)
527
+
528
+ // Load private key
529
+ pk, err = config.NewKeyFromKeystore(c.SequencerPrivateKey)
530
+ if err != nil {
531
+ log.Fatal(err)
532
+ }
533
+ }
534
+
535
+ agg, err := aggregator.New(c, st, ethTxManager, etherman, aggCli, pk)
536
  if err != nil {
537
  log.Fatal(err)
538
  }
 
602
  }
603
  log.Infof("Starting L1InfoRoot: %v", l1inforoot.String())
604
 
605
+ forkIDIntervals, err := forkIDIntervals(ctx, st, etherman, c.NetworkConfig.Genesis.RollupBlockNumber)
606
  if err != nil {
607
  log.Fatal("error getting forkIDs. Error: ", err)
608
  }
 
625
  }
626
 
627
  func createEthTxManager(cfg config.Config, etmStorage *ethtxmanager.PostgresStorage, st *state.State) *ethtxmanager.Client {
628
+ etherman, err := newEtherman(cfg, st)
629
  if err != nil {
630
  log.Fatal(err)
631
  }
632
 
633
  for _, privateKey := range cfg.EthTxManager.PrivateKeys {
634
+ _, _, err := etherman.LoadAuthFromKeyStore(privateKey.Path, privateKey.Password)
635
  if err != nil {
636
  log.Fatal(err)
637
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/set_data_availability_protocol.go RENAMED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package main
2
+
3
+ import (
4
+ "github.com/0xPolygonHermez/zkevm-node/config"
5
+ "github.com/0xPolygonHermez/zkevm-node/log"
6
+ "github.com/ethereum/go-ethereum/common"
7
+ "github.com/urfave/cli/v2"
8
+ )
9
+
10
+ const flagDAAddress = "data-availability-address"
11
+
12
+ var setDataAvailabilityProtocolFlags = []cli.Flag{
13
+ &cli.StringFlag{
14
+ Name: flagDAAddress,
15
+ Aliases: []string{"da-addr"},
16
+ Usage: "address of the new data availibility protocol",
17
+ Required: true,
18
+ },
19
+ &cli.StringFlag{
20
+ Name: config.FlagKeyStorePath,
21
+ Aliases: []string{"ksp"},
22
+ Usage: "the path of the key store file containing the private key of the account going to set new data availability protocol",
23
+ Required: true,
24
+ },
25
+ &cli.StringFlag{
26
+ Name: config.FlagPassword,
27
+ Aliases: []string{"pw"},
28
+ Usage: "the password do decrypt the key store file",
29
+ Required: true,
30
+ },
31
+ &configFileFlag,
32
+ &networkFlag,
33
+ &customNetworkFlag,
34
+ }
35
+
36
+ func setDataAvailabilityProtocol(ctx *cli.Context) error {
37
+ c, err := config.Load(ctx, true)
38
+ if err != nil {
39
+ return err
40
+ }
41
+
42
+ setupLog(c.Log)
43
+
44
+ daAddress := common.HexToAddress(ctx.String(flagDAAddress))
45
+ addrKeyStorePath := ctx.String(config.FlagKeyStorePath)
46
+ addrPassword := ctx.String(config.FlagPassword)
47
+
48
+ etherman, err := newEtherman(*c, nil)
49
+ if err != nil {
50
+ log.Fatal(err)
51
+ return err
52
+ }
53
+
54
+ auth, _, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword)
55
+ if err != nil {
56
+ log.Fatal(err)
57
+ return err
58
+ }
59
+
60
+ tx, err := etherman.SetDataAvailabilityProtocol(auth.From, daAddress)
61
+ if err != nil {
62
+ return err
63
+ }
64
+
65
+ log.Infof("Transaction to set new data availability protocol sent. Hash: %s", tx.Hash())
66
+
67
+ return nil
68
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/config/cardonagenesis.go RENAMED
@@ -1,109 +0,0 @@
1
- package config
2
-
3
- // CardonaNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup
4
- const CardonaNetworkConfigJSON = `
5
- {
6
- "l1Config": {
7
- "polygonZkEVMAddress": "0xA13Ddb14437A8F34897131367ad3ca78416d6bCa",
8
- "polygonZkEVMBridgeAddress": "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582",
9
- "polygonZkEVMGlobalExitRootAddress": "0xAd1490c248c5d3CbAE399Fd529b79B42984277DF",
10
- "polTokenAddress": "0x6a7c3F4B0651d6DA389AD1d11D962ea458cDCA70",
11
- "polygonRollupManagerAddress": "0x32d33D5137a7cFFb54c5Bf8371172bcEc5f310ff",
12
- "chainId": 11155111
13
- },
14
- "genesisBlockNumber": 4789190,
15
- "root": "0x91dfcdeb628dfdc51f3a2ee38cb17c78581e4e7ff91bcc2e327d24a9dfa46982",
16
- "genesis": [
17
- {
18
- "contractName": "PolygonZkEVMDeployer",
19
- "balance": "0",
20
- "nonce": "4",
21
- "address": "0x36810012486fc134D0679c07f85fe5ba5A087D8C",
22
- "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212203e70ce334e8ec9d8d03e87415afd36dce4e82633bd277b08937095a6bd66367764736f6c63430008110033",
23
- "storage": {
24
- "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000ff6250d0e86a2465b0c1bf8e36409503d6a26963"
25
- }
26
- },
27
- {
28
- "contractName": "ProxyAdmin",
29
- "balance": "0",
30
- "nonce": "1",
31
- "address": "0x85cEB41028B1a5ED2b88E395145344837308b251",
32
- "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220372a0e10eebea1b7fa43ae4c976994e6ed01d85eedc3637b83f01d3f06be442064736f6c63430008110033",
33
- "storage": {
34
- "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000dbc6981a11fc2b000c635bfa7c47676b25c87d39"
35
- }
36
- },
37
- {
38
- "contractName": "PolygonZkEVMBridge implementation",
39
- "balance": "0",
40
- "nonce": "1",
41
- "address": "0x8BD36ca1A55e389335004872aA3C3Be0969D3aA7",
42
- "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220d9b3ca7b13ec80ac58634ddf0ecebe71e209a71f532614949b9e720413f50c8364736f6c63430008110033"
43
- },
44
- {
45
- "contractName": "PolygonZkEVMBridge proxy",
46
- "balance": "200000000000000000000000000",
47
- "nonce": "1",
48
- "address": "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582",
49
- "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033",
50
- "storage": {
51
- "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001",
52
- "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001",
53
- "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100",
54
- "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000085ceb41028b1a5ed2b88e395145344837308b251",
55
- "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000008bd36ca1a55e389335004872aa3c3be0969d3aa7"
56
- }
57
- },
58
- {
59
- "contractName": "PolygonZkEVMGlobalExitRootL2 implementation",
60
- "balance": "0",
61
- "nonce": "1",
62
- "address": "0x282a631D9F3Ef04Bf1A44B4C9e8bDC8EB278917f",
63
- "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000528e26b25a34a4a5d0dbda1d57d318153d2ed58281565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000528e26b25a34a4a5d0dbda1d57d318153d2ed582161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033"
64
- },
65
- {
66
- "contractName": "PolygonZkEVMGlobalExitRootL2 proxy",
67
- "balance": "0",
68
- "nonce": "1",
69
- "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa",
70
- "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033",
71
- "storage": {
72
- "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000085ceb41028b1a5ed2b88e395145344837308b251",
73
- "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000282a631d9f3ef04bf1a44b4c9e8bdc8eb278917f"
74
- }
75
- },
76
- {
77
- "contractName": "PolygonZkEVMTimelock",
78
- "balance": "0",
79
- "nonce": "1",
80
- "address": "0xdbC6981a11fc2B000c635bFA7C47676b25C87D39",
81
- "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206416c4e08f97752b4bb06159524dac058d3dccd8775e57ef1b01505751ebf7af64736f6c63430008110033",
82
- "storage": {
83
- "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000e10",
84
- "0xf587dde6f8846415188f807710a3304f72092565918b30307d60efdc8014f20b": "0x0000000000000000000000000000000000000000000000000000000000000001",
85
- "0x07020fe9de9b8274d1e6cc0668a6f6344a870f35e5a847590c8069dfa85ac78f": "0x0000000000000000000000000000000000000000000000000000000000000001",
86
- "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
87
- "0xc8e266e0814671642b74f3807affd27009fcc23f713ea92d1743e0ee0c1e7603": "0x0000000000000000000000000000000000000000000000000000000000000001",
88
- "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
89
- "0x9b3efc411c5f69533db363941e091f6f3af8b7e306525413577a56d27e5dbe73": "0x0000000000000000000000000000000000000000000000000000000000000001",
90
- "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
91
- "0xa2001bdd6a5944149e83176d089ee9a8246bd56aecf38fe4d6c66f5fbac18675": "0x0000000000000000000000000000000000000000000000000000000000000001",
92
- "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5"
93
- }
94
- },
95
- {
96
- "accountName": "keyless Deployer",
97
- "balance": "0",
98
- "nonce": "1",
99
- "address": "0x1754175c450BEbB9B6E14dEe542649c0402A25d2"
100
- },
101
- {
102
- "accountName": "deployer",
103
- "balance": "100000000000000000000000",
104
- "nonce": "8",
105
- "address": "0xff6250d0E86A2465B0C1bF8e36409503d6a26963"
106
- }
107
- ]
108
- }
109
- `
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{/home/stefan/go/src/Polygon/zkevm-node → .}/config/config.go RENAMED
@@ -2,6 +2,8 @@
2
 
3
  import (
4
  "bytes"
 
 
5
  "path/filepath"
6
  "strings"
7
 
@@ -21,6 +24,7 @@
21
  "github.com/0xPolygonHermez/zkevm-node/state"
22
  "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
23
  "github.com/0xPolygonHermez/zkevm-node/synchronizer"
 
24
  "github.com/mitchellh/mapstructure"
25
  "github.com/spf13/viper"
26
  "github.com/urfave/cli/v2"
@@ -31,7 +35,7 @@
31
  FlagYes = "yes"
32
  // FlagCfg is the flag for cfg.
33
  FlagCfg = "cfg"
34
- // FlagNetwork is the flag for the network name. Valid values: ["testnet", "mainnet", "cardona", "custom"].
35
  FlagNetwork = "network"
36
  // FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom
37
  FlagCustomNetwork = "custom-network-file"
@@ -183,3 +187,19 @@
183
  }
184
  return cfg, nil
185
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  import (
4
  "bytes"
5
+ "crypto/ecdsa"
6
+ "os"
7
  "path/filepath"
8
  "strings"
9
 
 
24
  "github.com/0xPolygonHermez/zkevm-node/state"
25
  "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
26
  "github.com/0xPolygonHermez/zkevm-node/synchronizer"
27
+ "github.com/ethereum/go-ethereum/accounts/keystore"
28
  "github.com/mitchellh/mapstructure"
29
  "github.com/spf13/viper"
30
  "github.com/urfave/cli/v2"
 
35
  FlagYes = "yes"
36
  // FlagCfg is the flag for cfg.
37
  FlagCfg = "cfg"
38
+ // FlagNetwork is the flag for the network name. Valid values: ["custom"].
39
  FlagNetwork = "network"
40
  // FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom
41
  FlagCustomNetwork = "custom-network-file"
 
187
  }
188
  return cfg, nil
189
  }
190
+
191
+ // NewKeyFromKeystore creates a private key from a keystore file
192
+ func NewKeyFromKeystore(cfg types.KeystoreFileConfig) (*ecdsa.PrivateKey, error) {
193
+ if cfg.Path == "" && cfg.Password == "" {
194
+ return nil, nil
195
+ }
196
+ keystoreEncrypted, err := os.ReadFile(filepath.Clean(cfg.Path))
197
+ if err != nil {
198
+ return nil, err
199
+ }
200
+ key, err := keystore.DecryptKey(keystoreEncrypted, cfg.Password)
201
+ if err != nil {
202
+ return nil, err
203
+ }
204
+ return key.PrivateKey, nil
205
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/config/config_test.go RENAMED
@@ -174,24 +174,28 @@
174
  expectedValue: uint64(80000),
175
  },
176
  {
 
 
 
 
177
  path: "Etherman.URL",
178
  expectedValue: "http://localhost:8545",
179
  },
180
  {
181
  path: "NetworkConfig.L1Config.L1ChainID",
182
- expectedValue: uint64(5),
183
  },
184
  {
185
  path: "NetworkConfig.L1Config.ZkEVMAddr",
186
- expectedValue: common.HexToAddress("0xa997cfD539E703921fD1e3Cf25b4c241a27a4c7A"),
187
  },
188
  {
189
  path: "NetworkConfig.L1Config.PolAddr",
190
- expectedValue: common.HexToAddress("0x1319D23c2F7034F52Eb07399702B040bA278Ca49"),
191
  },
192
  {
193
  path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr",
194
- expectedValue: common.HexToAddress("0x4d9427DCA0406358445bC0a8F88C26b704004f74"),
195
  },
196
  {
197
  path: "Etherman.MultiGasProvider",
@@ -547,7 +551,8 @@
547
  require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600))
548
 
549
  flagSet := flag.NewFlagSet("", flag.PanicOnError)
550
- flagSet.String(config.FlagNetwork, "testnet", "")
 
551
  ctx := cli.NewContext(cli.NewApp(), flagSet, nil)
552
  cfg, err := config.Load(ctx, true)
553
  if err != nil {
@@ -585,7 +590,8 @@
585
  }()
586
  require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600))
587
  flagSet := flag.NewFlagSet("", flag.PanicOnError)
588
- flagSet.String(config.FlagNetwork, "testnet", "")
 
589
  ctx := cli.NewContext(cli.NewApp(), flagSet, nil)
590
 
591
  os.Setenv("ZKEVM_NODE_LOG_OUTPUTS", "a,b,c")
 
174
  expectedValue: uint64(80000),
175
  },
176
  {
177
+ path: "SequenceSender.MaxBatchesForL1",
178
+ expectedValue: uint64(300),
179
+ },
180
+ {
181
  path: "Etherman.URL",
182
  expectedValue: "http://localhost:8545",
183
  },
184
  {
185
  path: "NetworkConfig.L1Config.L1ChainID",
186
+ expectedValue: uint64(1337),
187
  },
188
  {
189
  path: "NetworkConfig.L1Config.ZkEVMAddr",
190
+ expectedValue: common.HexToAddress("0x8dAF17A20c9DBA35f005b6324F493785D239719d"),
191
  },
192
  {
193
  path: "NetworkConfig.L1Config.PolAddr",
194
+ expectedValue: common.HexToAddress("0x5FbDB2315678afecb367f032d93F642f64180aa3"),
195
  },
196
  {
197
  path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr",
198
+ expectedValue: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"),
199
  },
200
  {
201
  path: "Etherman.MultiGasProvider",
 
551
  require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600))
552
 
553
  flagSet := flag.NewFlagSet("", flag.PanicOnError)
554
+ flagSet.String(config.FlagNetwork, "custom", "")
555
+ flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "")
556
  ctx := cli.NewContext(cli.NewApp(), flagSet, nil)
557
  cfg, err := config.Load(ctx, true)
558
  if err != nil {
 
590
  }()
591
  require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600))
592
  flagSet := flag.NewFlagSet("", flag.PanicOnError)
593
+ flagSet.String(config.FlagNetwork, "custom", "")
594
+ flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "")
595
  ctx := cli.NewContext(cli.NewApp(), flagSet, nil)
596
 
597
  os.Setenv("ZKEVM_NODE_LOG_OUTPUTS", "a,b,c")
{/home/stefan/go/src/Polygon/zkevm-node → .}/config/default.go RENAMED
@@ -103,6 +103,8 @@
103
  SyncChunkSize = 100
104
  TrustedSequencerURL = "" # If it is empty or not specified, then the value is read from the smc
105
  L1SynchronizationMode = "sequential"
 
 
106
  [Synchronizer.L1ParallelSynchronization]
107
  MaxClients = 10
108
  MaxPendingNoProcessedBlocks = 25
@@ -158,6 +160,7 @@
158
  L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
159
  PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
160
  GasOffset = 80000
 
161
 
162
  [Aggregator]
163
  Host = "0.0.0.0"
@@ -172,6 +175,10 @@
172
  GasOffset = 0
173
  UpgradeEtrogBatchNumber = 0
174
  BatchProofL1BlockConfirmations = 2
 
 
 
 
175
 
176
  [L2GasPriceSuggester]
177
  Type = "follower"
 
103
  SyncChunkSize = 100
104
  TrustedSequencerURL = "" # If it is empty or not specified, then the value is read from the smc
105
  L1SynchronizationMode = "sequential"
106
+ L1SyncCheckL2BlockHash = true
107
+ L1SyncCheckL2BlockNumberhModulus = 30
108
  [Synchronizer.L1ParallelSynchronization]
109
  MaxClients = 10
110
  MaxPendingNoProcessedBlocks = 25
 
160
  L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
161
  PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
162
  GasOffset = 80000
163
+ MaxBatchesForL1 = 300
164
 
165
  [Aggregator]
166
  Host = "0.0.0.0"
 
175
  GasOffset = 0
176
  UpgradeEtrogBatchNumber = 0
177
  BatchProofL1BlockConfirmations = 2
178
+ SettlementBackend = "agglayer"
179
+ AggLayerTxTimeout = "5m"
180
+ AggLayerURL = "http://zkevm-agglayer"
181
+ SequencerPrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
182
 
183
  [L2GasPriceSuggester]
184
  Type = "follower"
{/home/stefan/go/src/Polygon/zkevm-node → .}/config/mainnetgenesis.go RENAMED
@@ -1,108 +0,0 @@
1
- package config
2
-
3
- // MainnetNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup
4
- const MainnetNetworkConfigJSON = `
5
- {
6
- "l1Config" : {
7
- "chainId": 1,
8
- "polygonZkEVMAddress": "0x519E42c24163192Dca44CD3fBDCEBF6be9130987",
9
- "polygonRollupManagerAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2",
10
- "polTokenAddress": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6",
11
- "polygonZkEVMGlobalExitRootAddress": "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb"
12
- },
13
- "root": "0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9",
14
- "genesisBlockNumber": 16896721,
15
- "genesis": [
16
- {
17
- "contractName": "PolygonZkEVMDeployer",
18
- "balance": "0",
19
- "nonce": "4",
20
- "address": "0xCB19eDdE626906eB1EE52357a27F62dd519608C2",
21
- "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212203e70ce334e8ec9d8d03e87415afd36dce4e82633bd277b08937095a6bd66367764736f6c63430008110033",
22
- "storage": {
23
- "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000004c1665d6651ecefa59b9b3041951608468b18891"
24
- }
25
- },
26
- {
27
- "contractName": "ProxyAdmin",
28
- "balance": "0",
29
- "nonce": "1",
30
- "address": "0x0F99738B2Fc14D77308337f3e2596b63aE7BCC4A",
31
- "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220372a0e10eebea1b7fa43ae4c976994e6ed01d85eedc3637b83f01d3f06be442064736f6c63430008110033",
32
- "storage": {
33
- "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000bba0935fa93eb23de7990b47f0d96a8f75766d13"
34
- }
35
- },
36
- {
37
- "contractName": "PolygonZkEVMBridge implementation",
38
- "balance": "0",
39
- "nonce": "1",
40
- "address": "0x5ac4182A1dd41AeEf465E40B82fd326BF66AB82C",
41
- "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220d9b3ca7b13ec80ac58634ddf0ecebe71e209a71f532614949b9e720413f50c8364736f6c63430008110033"
42
- },
43
- {
44
- "contractName": "PolygonZkEVMBridge proxy",
45
- "balance": "200000000000000000000000000",
46
- "nonce": "1",
47
- "address": "0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe",
48
- "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033",
49
- "storage": {
50
- "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001",
51
- "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001",
52
- "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100",
53
- "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x0000000000000000000000000f99738b2fc14d77308337f3e2596b63ae7bcc4a",
54
- "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000005ac4182a1dd41aeef465e40b82fd326bf66ab82c"
55
- }
56
- },
57
- {
58
- "contractName": "PolygonZkEVMGlobalExitRootL2 implementation",
59
- "balance": "0",
60
- "nonce": "1",
61
- "address": "0x0200143Fa295EE4dffEF22eE2616c2E008D81688",
62
- "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f0000000000000000000000002a3dd3eb832af982ec71669e178424b10dca2ede81565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000002a3dd3eb832af982ec71669e178424b10dca2ede161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033"
63
- },
64
- {
65
- "contractName": "PolygonZkEVMGlobalExitRootL2 proxy",
66
- "balance": "0",
67
- "nonce": "1",
68
- "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa",
69
- "bytecode": "0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106ca565b610118565b61005b6100933660046106e5565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106ca565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103f1565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107e460279139610445565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb610519565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b83610541565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806103dc5750805b156101c3576103eb8383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61041a61035f565b604080516001600160a01b03928316815291841660208301520160405180910390a1610154816105e9565b6060833b6104a45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b0316856040516104bf9190610794565b600060405180830381855af49150503d80600081146104fa576040519150601f19603f3d011682016040523d82523d6000602084013e6104ff565b606091505b509150915061050f828286610675565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b803b6105a55760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b03811661064e5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036105c8565b60608315610684575081610285565b8251156106945782518084602001fd5b8160405162461bcd60e51b815260040161032891906107b0565b80356001600160a01b03811681146106c557600080fd5b919050565b6000602082840312156106dc57600080fd5b610285826106ae565b6000806000604084860312156106fa57600080fd5b610703846106ae565b9250602084013567ffffffffffffffff8082111561072057600080fd5b818601915086601f83011261073457600080fd5b81358181111561074357600080fd5b87602082850101111561075557600080fd5b6020830194508093505050509250925092565b60005b8381101561078357818101518382015260200161076b565b838111156103eb5750506000910152565b600082516107a6818460208701610768565b9190910192915050565b60208152600082518060208401526107cf816040850160208701610768565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204675187caf3a43285d9a2c1844a981e977bd52a85ff073e7fc649f73847d70a464736f6c63430008090033",
70
- "storage": {
71
- "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x0000000000000000000000000f99738b2fc14d77308337f3e2596b63ae7bcc4a",
72
- "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000000200143fa295ee4dffef22ee2616c2e008d81688"
73
- }
74
- },
75
- {
76
- "contractName": "PolygonZkEVMTimelock",
77
- "balance": "0",
78
- "nonce": "1",
79
- "address": "0xBBa0935Fa93Eb23de7990b47F0D96a8f75766d13",
80
- "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206416c4e08f97752b4bb06159524dac058d3dccd8775e57ef1b01505751ebf7af64736f6c63430008110033",
81
- "storage": {
82
- "0x0000000000000000000000000000000000000000000000000000000000000002": "0x00000000000000000000000000000000000000000000000000000000000d2f00",
83
- "0x33d4aa03df3f12c4f615b40676f67fdafecd3edb5a9c0ca2a47a923dae33a023": "0x0000000000000000000000000000000000000000000000000000000000000001",
84
- "0x9fa2d8034dbcb437bee38d61fbd100910e1342ffc07f128aa1b8e6790b7f3f68": "0x0000000000000000000000000000000000000000000000000000000000000001",
85
- "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
86
- "0x531a7c25761aa4b0f2310edca9bb25e1e3ceb49ad4b0422aec866b3ce7567c87": "0x0000000000000000000000000000000000000000000000000000000000000001",
87
- "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
88
- "0xedbedc78c4240c7613622a35de050b48bd6c6d9a31b3d485b68fbbed54a4802d": "0x0000000000000000000000000000000000000000000000000000000000000001",
89
- "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
90
- "0x76616448da8d124a07383c26a6b2433b3259de946aa40f51524ec96ee05e871a": "0x0000000000000000000000000000000000000000000000000000000000000001",
91
- "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5"
92
- }
93
- },
94
- {
95
- "accountName": "keyless Deployer",
96
- "balance": "0",
97
- "nonce": "1",
98
- "address": "0x9d90066e7478496e2284E54c3548106bb4F90E50"
99
- },
100
- {
101
- "accountName": "deployer",
102
- "balance": "0",
103
- "nonce": "8",
104
- "address": "0x4c1665d6651ecEfa59B9B3041951608468b18891"
105
- }
106
- ]
107
- }
108
- `
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{/home/stefan/go/src/Polygon/zkevm-node → .}/config/network.go RENAMED
@@ -25,17 +25,16 @@
25
 
26
  type network string
27
 
28
- const mainnet network = "mainnet"
29
- const testnet network = "testnet"
30
- const cardona network = "cardona"
31
  const custom network = "custom"
32
 
33
  // GenesisFromJSON is the config file for network_custom
34
  type GenesisFromJSON struct {
35
  // L1: root hash of the genesis block
36
  Root string `json:"root"`
37
- // L1: block number of the genesis block
38
- GenesisBlockNum uint64 `json:"genesisBlockNumber"`
 
 
39
  // L2: List of states contracts used to populate merkle tree at initial state
40
  Genesis []genesisAccountFromJSON `json:"genesis"`
41
  // L1: configuration of the network
@@ -60,12 +59,6 @@
60
  func (cfg *Config) loadNetworkConfig(ctx *cli.Context) {
61
  var networkJSON string
62
  switch ctx.String(FlagNetwork) {
63
- case string(mainnet):
64
- networkJSON = MainnetNetworkConfigJSON
65
- case string(testnet):
66
- networkJSON = TestnetNetworkConfigJSON
67
- case string(cardona):
68
- networkJSON = CardonaNetworkConfigJSON
69
  case string(custom):
70
  var err error
71
  cfgPath := ctx.String(FlagCustomNetwork)
@@ -74,7 +67,7 @@
74
  panic(err.Error())
75
  }
76
  default:
77
- log.Fatalf("unsupported --network value. Must be one of: [%s, %s, %s]", mainnet, testnet, cardona, custom)
78
  }
79
  config, err := LoadGenesisFromJSONString(networkJSON)
80
  if err != nil {
@@ -122,9 +115,10 @@
122
 
123
  cfg.L1Config = cfgJSON.L1Config
124
  cfg.Genesis = state.Genesis{
125
- BlockNumber: cfgJSON.GenesisBlockNum,
126
- Root: common.HexToHash(cfgJSON.Root),
127
- Actions: []*state.GenesisAction{},
 
128
  }
129
 
130
  for _, account := range cfgJSON.Genesis {
 
25
 
26
  type network string
27
 
 
 
 
28
  const custom network = "custom"
29
 
30
  // GenesisFromJSON is the config file for network_custom
31
  type GenesisFromJSON struct {
32
  // L1: root hash of the genesis block
33
  Root string `json:"root"`
34
+ // L1: block number in which the rollup was created
35
+ RollupCreationBlockNum uint64 `json:"rollupCreationBlockNumber"`
36
+ // L1: block number in which the rollup manager was created
37
+ RollupManagerCreationBlockNum uint64 `json:"rollupManagerCreationBlockNumber"`
38
  // L2: List of states contracts used to populate merkle tree at initial state
39
  Genesis []genesisAccountFromJSON `json:"genesis"`
40
  // L1: configuration of the network
 
59
  func (cfg *Config) loadNetworkConfig(ctx *cli.Context) {
60
  var networkJSON string
61
  switch ctx.String(FlagNetwork) {
 
 
 
 
 
 
62
  case string(custom):
63
  var err error
64
  cfgPath := ctx.String(FlagCustomNetwork)
 
67
  panic(err.Error())
68
  }
69
  default:
70
+ log.Fatalf("unsupported --network value. Must be %s", custom)
71
  }
72
  config, err := LoadGenesisFromJSONString(networkJSON)
73
  if err != nil {
 
115
 
116
  cfg.L1Config = cfgJSON.L1Config
117
  cfg.Genesis = state.Genesis{
118
+ RollupBlockNumber: cfgJSON.RollupCreationBlockNum,
119
+ RollupManagerBlockNumber: cfgJSON.RollupManagerCreationBlockNum,
120
+ Root: common.HexToHash(cfgJSON.Root),
121
+ Actions: []*state.GenesisAction{},
122
  }
123
 
124
  for _, account := range cfgJSON.Genesis {
{/home/stefan/go/src/Polygon/zkevm-node → .}/config/network_test.go RENAMED
@@ -14,18 +13,6 @@
14
  "github.com/urfave/cli/v2"
15
  )
16
 
17
- func TestCardona(t *testing.T) {
18
- cfg := Config{}
19
- fs := flag.NewFlagSet("", flag.ExitOnError)
20
- fs.String(FlagNetwork, string(cardona), string(cardona))
21
- err := fs.Set(FlagNetwork, string(cardona))
22
- require.NoError(t, err)
23
- app := cli.NewApp()
24
- ctx := cli.NewContext(app, fs, nil)
25
-
26
- log.Info("flag=", ctx.String(FlagNetwork))
27
- cfg.loadNetworkConfig(ctx)
28
- }
29
  func TestLoadCustomNetworkConfig(t *testing.T) {
30
  tcs := []struct {
31
  description string
@@ -37,7 +24,8 @@
37
  description: "happy path",
38
  inputConfigStr: `{
39
  "root": "0xBEEF",
40
- "genesisBlockNumber": 69,
 
41
  "l1Config" : {
42
  "chainId": 420,
43
  "polygonZkEVMAddress": "0xc949254d682d8c9ad5682521675b8f43b102aec4",
@@ -89,8 +77,9 @@
89
  GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"),
90
  },
91
  Genesis: state.Genesis{
92
- Root: common.HexToHash("0xBEEF"),
93
- BlockNumber: 69,
 
94
  Actions: []*state.GenesisAction{
95
  {
96
  Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4",
 
13
  "github.com/urfave/cli/v2"
14
  )
15
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  func TestLoadCustomNetworkConfig(t *testing.T) {
17
  tcs := []struct {
18
  description string
 
24
  description: "happy path",
25
  inputConfigStr: `{
26
  "root": "0xBEEF",
27
+ "rollupCreationBlockNumber": 69,
28
+ "rollupManagerCreationBlockNumber": 60,
29
  "l1Config" : {
30
  "chainId": 420,
31
  "polygonZkEVMAddress": "0xc949254d682d8c9ad5682521675b8f43b102aec4",
 
77
  GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"),
78
  },
79
  Genesis: state.Genesis{
80
+ Root: common.HexToHash("0xBEEF"),
81
+ RollupBlockNumber: 69,
82
+ RollupManagerBlockNumber: 60,
83
  Actions: []*state.GenesisAction{
84
  {
85
  Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4",
{/home/stefan/go/src/Polygon/zkevm-node → .}/config/testnetgenesis.go RENAMED
@@ -1,108 +0,0 @@
1
- package config
2
-
3
- // TestnetNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup
4
- const TestnetNetworkConfigJSON = `
5
- {
6
- "l1Config" : {
7
- "chainId": 5,
8
- "polygonZkEVMAddress": "0xa997cfD539E703921fD1e3Cf25b4c241a27a4c7A",
9
- "polTokenAddress": "0x1319D23c2F7034F52Eb07399702B040bA278Ca49",
10
- "polygonZkEVMGlobalExitRootAddress": "0x4d9427DCA0406358445bC0a8F88C26b704004f74"
11
- },
12
- "root": "0x13a14c4a8288e782863d7ce916d224546c69dc428fbfa7115a0cc33a27a05b26",
13
- "genesisBlockNumber": 8572998,
14
- "genesis": [
15
- {
16
- "contractName": "PolygonZkEVMDeployer",
17
- "balance": "0",
18
- "nonce": "4",
19
- "address": "0x39877a0c3cd148476DaA2475c77c478C62eC7509",
20
- "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212200b8e3cd6bd762444a7eeff86e1cfcd7e1ce9524b715dcb70b2a4c2b70fd5188464736f6c63430008110033",
21
- "storage": {
22
- "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000a0b02b28920812324f1cc3255bd8840867d3f227"
23
- }
24
- },
25
- {
26
- "contractName": "ProxyAdmin",
27
- "balance": "0",
28
- "nonce": "1",
29
- "address": "0x40797c2f93298a44a893F43EdF1B33B63d7BA333",
30
- "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220babd4ff1f5daee002b96cc86d8bb6c2c2c210ae3132df5ea384713352f7f15fe64736f6c63430008110033",
31
- "storage": {
32
- "0x0000000000000000000000000000000000000000000000000000000000000000": "0x00000000000000000000000002245d7b6cb0b6870d1e28ac877ee355b9588869"
33
- }
34
- },
35
- {
36
- "contractName": "PolygonZkEVMBridge implementation",
37
- "balance": "0",
38
- "nonce": "1",
39
- "address": "0x39e780D8800f7396e8B7530A8925B14025AedC77",
40
- "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220addfd62f466d34ee002afbb4ae37b6be56ad421fe773f800badeb4ce1025089864736f6c63430008110033"
41
- },
42
- {
43
- "contractName": "PolygonZkEVMBridge proxy",
44
- "balance": "200000000000000000000000000",
45
- "nonce": "1",
46
- "address": "0xF6BEEeBB578e214CA9E23B0e9683454Ff88Ed2A7",
47
- "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033",
48
- "storage": {
49
- "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001",
50
- "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001",
51
- "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100",
52
- "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000040797c2f93298a44a893f43edf1b33b63d7ba333",
53
- "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x00000000000000000000000039e780d8800f7396e8b7530a8925b14025aedc77"
54
- }
55
- },
56
- {
57
- "contractName": "PolygonZkEVMGlobalExitRootL2 implementation",
58
- "balance": "0",
59
- "nonce": "1",
60
- "address": "0x77Fc57b154fCF8320Df2C2e6C044AA50141c023b",
61
- "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000f6beeebb578e214ca9e23b0e9683454ff88ed2a781565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000f6beeebb578e214ca9e23b0e9683454ff88ed2a7161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033"
62
- },
63
- {
64
- "contractName": "PolygonZkEVMGlobalExitRootL2 proxy",
65
- "balance": "0",
66
- "nonce": "1",
67
- "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa",
68
- "bytecode": "0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106ca565b610118565b61005b6100933660046106e5565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106ca565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103f1565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107e460279139610445565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb610519565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b83610541565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806103dc5750805b156101c3576103eb8383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61041a61035f565b604080516001600160a01b03928316815291841660208301520160405180910390a1610154816105e9565b6060833b6104a45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b0316856040516104bf9190610794565b600060405180830381855af49150503d80600081146104fa576040519150601f19603f3d011682016040523d82523d6000602084013e6104ff565b606091505b509150915061050f828286610675565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b803b6105a55760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b03811661064e5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036105c8565b60608315610684575081610285565b8251156106945782518084602001fd5b8160405162461bcd60e51b815260040161032891906107b0565b80356001600160a01b03811681146106c557600080fd5b919050565b6000602082840312156106dc57600080fd5b610285826106ae565b6000806000604084860312156106fa57600080fd5b610703846106ae565b9250602084013567ffffffffffffffff8082111561072057600080fd5b818601915086601f83011261073457600080fd5b81358181111561074357600080fd5b87602082850101111561075557600080fd5b6020830194508093505050509250925092565b60005b8381101561078357818101518382015260200161076b565b838111156103eb5750506000910152565b600082516107a6818460208701610768565b9190910192915050565b60208152600082518060208401526107cf816040850160208701610768565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204675187caf3a43285d9a2c1844a981e977bd52a85ff073e7fc649f73847d70a464736f6c63430008090033",
69
- "storage": {
70
- "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000040797c2f93298a44a893f43edf1b33b63d7ba333",
71
- "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x00000000000000000000000077fc57b154fcf8320df2c2e6c044aa50141c023b"
72
- }
73
- },
74
- {
75
- "contractName": "PolygonZkEVMTimelock",
76
- "balance": "0",
77
- "nonce": "1",
78
- "address": "0x02245d7B6CB0b6870d1e28AC877EE355b9588869",
79
- "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c12565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611c87565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611cc9565b6107df565b3480156102be57600080fd5b506102146102cd366004611d35565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e5a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d35565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d35565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611ec2565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d35565b610927565b3480156103f457600080fd5b506101f2610403366004611ec2565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d35565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d35565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611cc9565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f33565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611ec2565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004611fe5565b610d4f565b3480156105db57600080fd5b506103166105ea36600461210e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d35565b610d94565b34801561064057600080fd5b5061025d61064f366004611d35565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611ec2565b610e8f565b6101f261068f366004611fe5565b610eb4565b3480156106a057600080fd5b506103166106af3660046121b8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611204565b6000610728898989898989610ade565b90506107348184611211565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a60405161077096959493929190612266565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261135e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c81336113f5565b600061086c888888888888610ade565b905061087881856114ad565b610884888888886115ea565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122b1565b60405180910390a36108cd816116ee565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611204565b6109228383611797565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f48282611887565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb96959493929190612266565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611204565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611211565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc36122f1565b9050602002016020810190610cd89190612320565b8d8d86818110610cea57610cea6122f1565b905060200201358c8c87818110610d0357610d036122f1565b9050602002810190610d15919061233b565b8c8b604051610d2996959493929190612266565b60405180910390a3610d3a816123cf565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124b7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611204565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611204565b6109228383611887565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f3181336113f5565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ad565b60005b8981101561114b5760008b8b8381811061108c5761108c6122f1565b90506020020160208101906110a19190612320565b905060008a8a848181106110b7576110b76122f1565b9050602002013590503660008a8a868181106110d5576110d56122f1565b90506020028101906110e7919061233b565b915091506110f7848484846115ea565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122b1565b60405180910390a35050505080611144906123cf565b9050611070565b50611155816116ee565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f2919061257e565b156111fd5750600090565b5060025490565b61120e81336113f5565b50565b61121a82610927565b156112a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112af611161565b81101561133e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61134881426125a0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114338161193e565b61143e83602061195d565b60405160200161144f9291906125d7565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612658565b6114b6826108d7565b611542576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061155e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116149291906126a9565b60006040518083038185875af1925050503d8060008114611651576040519150601f19603f3d011682016040523d82523d6000602084013e611656565b606091505b50509050806116e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b6116f7816108d7565b611783576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118293390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b6060600061196c8360026126b9565b6119779060026125a0565b67ffffffffffffffff81111561198f5761198f611d4e565b6040519080825280601f01601f1916602001820160405280156119b9576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106119f0576119f06122f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a5357611a536122f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611a8f8460026126b9565b611a9a9060016125a0565b90505b6001811115611b37577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611adb57611adb6122f1565b1a60f81b828281518110611af157611af16122f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b30816126d0565b9050611a9d565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611bc457600080fd5b919050565b60008083601f840112611bdb57600080fd5b50813567ffffffffffffffff811115611bf357600080fd5b602083019150836020828501011115611c0b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c2d57600080fd5b611c3688611ba0565b965060208801359550604088013567ffffffffffffffff811115611c5957600080fd5b611c658a828b01611bc9565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611c9957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611ce257600080fd5b611ceb87611ba0565b955060208701359450604087013567ffffffffffffffff811115611d0e57600080fd5b611d1a89828a01611bc9565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d4757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611dc457611dc4611d4e565b604052919050565b600082601f830112611ddd57600080fd5b813567ffffffffffffffff811115611df757611df7611d4e565b611e2860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611d7d565b818152846020838601011115611e3d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611e7057600080fd5b611e7985611ba0565b9350611e8760208601611ba0565b925060408501359150606085013567ffffffffffffffff811115611eaa57600080fd5b611eb687828801611dcc565b91505092959194509250565b60008060408385031215611ed557600080fd5b82359150611ee560208401611ba0565b90509250929050565b60008083601f840112611f0057600080fd5b50813567ffffffffffffffff811115611f1857600080fd5b6020830191508360208260051b8501011115611c0b57600080fd5b600080600080600080600080600060c08a8c031215611f5157600080fd5b893567ffffffffffffffff80821115611f6957600080fd5b611f758d838e01611eee565b909b50995060208c0135915080821115611f8e57600080fd5b611f9a8d838e01611eee565b909950975060408c0135915080821115611fb357600080fd5b50611fc08c828d01611eee565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561200157600080fd5b883567ffffffffffffffff8082111561201957600080fd5b6120258c838d01611eee565b909a50985060208b013591508082111561203e57600080fd5b61204a8c838d01611eee565b909850965060408b013591508082111561206357600080fd5b506120708b828c01611eee565b999c989b509699959896976060870135966080013595509350505050565b600082601f83011261209f57600080fd5b8135602067ffffffffffffffff8211156120bb576120bb611d4e565b8160051b6120ca828201611d7d565b92835284810182019282810190878511156120e457600080fd5b83870192505b84831015612103578235825291830191908301906120ea565b979650505050505050565b600080600080600060a0868803121561212657600080fd5b61212f86611ba0565b945061213d60208701611ba0565b9350604086013567ffffffffffffffff8082111561215a57600080fd5b61216689838a0161208e565b9450606088013591508082111561217c57600080fd5b61218889838a0161208e565b9350608088013591508082111561219e57600080fd5b506121ab88828901611dcc565b9150509295509295909350565b600080600080600060a086880312156121d057600080fd5b6121d986611ba0565b94506121e760208701611ba0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561221157600080fd5b6121ab88828901611dcc565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a06040820152600061229c60a08301868861221d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff851681528360208201526060604082015260006122e760608301848661221d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561233257600080fd5b6108f682611ba0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261237057600080fd5b83018035915067ffffffffffffffff82111561238b57600080fd5b602001915036819003821315611c0b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612400576124006123a0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124aa57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe188360301811261246057600080fd5b8701858101903567ffffffffffffffff81111561247c57600080fd5b80360382131561248b57600080fd5b61249686828461221d565b9a87019a9550505090840190600101612421565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125055773ffffffffffffffffffffffffffffffffffffffff6124f084611ba0565b168252602092830192909101906001016124ca565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561253e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125669082018789612407565b60608401959095525050608001529695505050505050565b60006020828403121561259057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123a0565b60005b838110156125ce5781810151838201526020016125b6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161260f8160178501602088016125b3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161264c8160288401602088016125b3565b01602801949350505050565b60208152600082518060208401526126778160408501602087016125b3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123a0565b6000816126df576126df6123a0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220288c3dd40a2ba96edf066502722584177809ebdb47c0cf9ee8df6f07954c373064736f6c63430008110033",
80
- "storage": {
81
- "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000015180",
82
- "0xbdd73c6ebfb442c137537be0985acf11af8e6133078bc51ef9094071cb0ca475": "0x0000000000000000000000000000000000000000000000000000000000000001",
83
- "0x92b79801e6a3d148a516c908cc0bbad93771fa74468b7757a14aa55532d092de": "0x0000000000000000000000000000000000000000000000000000000000000001",
84
- "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
85
- "0x43e090632490f7d46c400129311fff008a7688bb3d4aebdf80607456b452cf04": "0x0000000000000000000000000000000000000000000000000000000000000001",
86
- "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
87
- "0x5af21cf0316499c6925cf9be0331b8bd150a1fa4c19d24a043b45f0cf15357c3": "0x0000000000000000000000000000000000000000000000000000000000000001",
88
- "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5",
89
- "0xaf021eeb38644155cd697b3ce0ec4fdac818d29c448a9f9d9bafc293723c6cd8": "0x0000000000000000000000000000000000000000000000000000000000000001",
90
- "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5"
91
- }
92
- },
93
- {
94
- "accountName": "keyless Deployer",
95
- "balance": "0",
96
- "nonce": "1",
97
- "address": "0xB83a574B3966F7dc1d38d162FA154F2A57D608Bb"
98
- },
99
- {
100
- "accountName": "deployer",
101
- "balance": "0",
102
- "nonce": "8",
103
- "address": "0xA0B02B28920812324f1cC3255bd8840867d3f227"
104
- }
105
- ]
106
- }
107
-
108
- `
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{/home/stefan/go/src/Polygon/zkevm-node → .}/config/types/duration.go RENAMED
@@ -38,3 +38,13 @@
38
  },
39
  }
40
  }
 
 
 
 
 
 
 
 
 
 
 
38
  },
39
  }
40
  }
41
+
42
+ // MarshalJSON marshalls time duration into text.
43
+ func (d Duration) MarshalJSON() ([]byte, error) {
44
+ return []byte(`"` + d.String() + `"`), nil
45
+ }
46
+
47
+ // MarshalText marshalls time duration into text.
48
+ func (d *Duration) MarshalText() ([]byte, error) {
49
+ return []byte(d.String()), nil
50
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/config.go RENAMED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ package dataavailability
2
+
3
+ // DABackendType is the data availability protocol for the CDK
4
+ type DABackendType string
5
+
6
+ const (
7
+ // DataAvailabilityCommittee is the DAC protocol backend
8
+ DataAvailabilityCommittee DABackendType = "DataAvailabilityCommittee"
9
+ )
{/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/dataavailability.go RENAMED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package dataavailability
2
+
3
+ import (
4
+ "context"
5
+ "fmt"
6
+ "math/big"
7
+
8
+ "github.com/0xPolygonHermez/zkevm-node/etherman/types"
9
+ "github.com/0xPolygonHermez/zkevm-node/log"
10
+ "github.com/ethereum/go-ethereum/common"
11
+ "github.com/ethereum/go-ethereum/crypto"
12
+ )
13
+
14
+ const unexpectedHashTemplate = "mismatch on transaction data for batch num %d. Expected hash %s, actual hash: %s"
15
+
16
+ // DataAvailability implements an abstract data availability integration
17
+ type DataAvailability struct {
18
+ isTrustedSequencer bool
19
+
20
+ state stateInterface
21
+ zkEVMClient ZKEVMClientTrustedBatchesGetter
22
+ backend DABackender
23
+
24
+ ctx context.Context
25
+ }
26
+
27
+ // New creates a DataAvailability instance
28
+ func New(
29
+ isTrustedSequencer bool,
30
+ backend DABackender,
31
+ state stateInterface,
32
+ zkEVMClient ZKEVMClientTrustedBatchesGetter,
33
+ ) (*DataAvailability, error) {
34
+ da := &DataAvailability{
35
+ isTrustedSequencer: isTrustedSequencer,
36
+ backend: backend,
37
+ state: state,
38
+ zkEVMClient: zkEVMClient,
39
+ ctx: context.Background(),
40
+ }
41
+ err := da.backend.Init()
42
+ return da, err
43
+ }
44
+
45
+ // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage
46
+ // as expected by the contract
47
+ func (d *DataAvailability) PostSequence(ctx context.Context, sequences []types.Sequence) ([]byte, error) {
48
+ batchesData := [][]byte{}
49
+ for _, batch := range sequences {
50
+ // Do not send to the DA backend data that will be stored to L1
51
+ if batch.ForcedBatchTimestamp == 0 {
52
+ batchesData = append(batchesData, batch.BatchL2Data)
53
+ }
54
+ }
55
+ return d.backend.PostSequence(ctx, batchesData)
56
+ }
57
+
58
+ // GetBatchL2Data tries to return the data from a batch, in the following priorities
59
+ // 1. From local DB
60
+ // 2. From Sequencer
61
+ // 3. From DA backend
62
+ func (d *DataAvailability) GetBatchL2Data(batchNums []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) {
63
+ if len(batchNums) != len(batchHashes) {
64
+ return nil, fmt.Errorf("invalid L2 batch data retrieval arguments, %d != %d", len(batchNums), len(batchHashes))
65
+ }
66
+
67
+ data, err := d.localData(batchNums, batchHashes)
68
+ if err == nil {
69
+ return data, nil
70
+ }
71
+
72
+ if !d.isTrustedSequencer {
73
+ data, err = d.trustedSequencerData(batchNums, batchHashes)
74
+ if err != nil {
75
+ log.Warnf("trusted sequencer failed to return data for batches %v: %s", batchNums, err.Error())
76
+ } else {
77
+ return data, nil
78
+ }
79
+ }
80
+
81
+ return d.backend.GetSequence(d.ctx, batchHashes, dataAvailabilityMessage)
82
+ }
83
+
84
+ // localData retrieves batches from local database and returns an error unless all are found
85
+ func (d *DataAvailability) localData(numbers []uint64, hashes []common.Hash) ([][]byte, error) {
86
+ data, err := d.state.GetBatchL2DataByNumbers(d.ctx, numbers, nil)
87
+ if err != nil {
88
+ return nil, err
89
+ }
90
+ var batches [][]byte
91
+ for i := 0; i < len(numbers); i++ {
92
+ batchNumber := numbers[i]
93
+ expectedHash := hashes[i]
94
+ batchData, ok := data[batchNumber]
95
+ if !ok {
96
+ return nil, fmt.Errorf("missing batch %v", batchNumber)
97
+ }
98
+ actualHash := crypto.Keccak256Hash(batchData)
99
+ if actualHash != expectedHash {
100
+ err = fmt.Errorf(unexpectedHashTemplate, batchNumber, expectedHash, actualHash)
101
+ log.Warnf("wrong local data for hash: %s", err.Error())
102
+ return nil, err
103
+ } else {
104
+ batches = append(batches, batchData)
105
+ }
106
+ }
107
+ return batches, nil
108
+ }
109
+
110
+ // trustedSequencerData retrieved batch data from the trusted sequencer and returns an error unless all are found
111
+ func (d *DataAvailability) trustedSequencerData(batchNums []uint64, expectedHashes []common.Hash) ([][]byte, error) {
112
+ if len(batchNums) != len(expectedHashes) {
113
+ return nil, fmt.Errorf("invalid arguments, len of batch numbers does not equal length of expected hashes: %d != %d",
114
+ len(batchNums), len(expectedHashes))
115
+ }
116
+ var nums []*big.Int
117
+ for _, n := range batchNums {
118
+ nums = append(nums, new(big.Int).SetUint64(n))
119
+ }
120
+ batchData, err := d.zkEVMClient.BatchesByNumbers(d.ctx, nums)
121
+ if err != nil {
122
+ return nil, err
123
+ }
124
+ if len(batchData) != len(batchNums) {
125
+ return nil, fmt.Errorf("missing batch data, expected %d, got %d", len(batchNums), len(batchData))
126
+ }
127
+ var result [][]byte
128
+ for i := 0; i < len(batchNums); i++ {
129
+ number := batchNums[i]
130
+ batch := batchData[i]
131
+ expectedTransactionsHash := expectedHashes[i]
132
+ actualTransactionsHash := crypto.Keccak256Hash(batch.BatchL2Data)
133
+ if expectedTransactionsHash != actualTransactionsHash {
134
+ return nil, fmt.Errorf(unexpectedHashTemplate, number, expectedTransactionsHash, actualTransactionsHash)
135
+ }
136
+ result = append(result, batch.BatchL2Data)
137
+ }
138
+ return result, nil
139
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee.go RENAMED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package datacommittee
2
+
3
+ import (
4
+ "crypto/ecdsa"
5
+ "errors"
6
+ "fmt"
7
+ "math/big"
8
+ "math/rand"
9
+ "sort"
10
+ "strings"
11
+
12
+ "github.com/0xPolygon/cdk-data-availability/client"
13
+ daTypes "github.com/0xPolygon/cdk-data-availability/types"
14
+ "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee"
15
+ "github.com/0xPolygonHermez/zkevm-node/log"
16
+ "github.com/ethereum/go-ethereum/accounts/abi/bind"
17
+ "github.com/ethereum/go-ethereum/common"
18
+ "github.com/ethereum/go-ethereum/crypto"
19
+ "github.com/ethereum/go-ethereum/ethclient"
20
+ "golang.org/x/net/context"
21
+ )
22
+
23
+ const unexpectedHashTemplate = "missmatch on transaction data. Expected hash %s, actual hash: %s"
24
+
25
+ // DataCommitteeMember represents a member of the Data Committee
26
+ type DataCommitteeMember struct {
27
+ Addr common.Address
28
+ URL string
29
+ }
30
+
31
+ // DataCommittee represents a specific committee
32
+ type DataCommittee struct {
33
+ AddressesHash common.Hash
34
+ Members []DataCommitteeMember
35
+ RequiredSignatures uint64
36
+ }
37
+
38
+ // DataCommitteeBackend implements the DAC integration
39
+ type DataCommitteeBackend struct {
40
+ dataCommitteeContract *polygondatacommittee.Polygondatacommittee
41
+ privKey *ecdsa.PrivateKey
42
+ dataCommitteeClientFactory client.Factory
43
+
44
+ committeeMembers []DataCommitteeMember
45
+ selectedCommitteeMember int
46
+ ctx context.Context
47
+ }
48
+
49
+ // New creates an instance of DataCommitteeBackend
50
+ func New(
51
+ l1RPCURL string,
52
+ dataCommitteeAddr common.Address,
53
+ privKey *ecdsa.PrivateKey,
54
+ dataCommitteeClientFactory client.Factory,
55
+ ) (*DataCommitteeBackend, error) {
56
+ ethClient, err := ethclient.Dial(l1RPCURL)
57
+ if err != nil {
58
+ log.Errorf("error connecting to %s: %+v", l1RPCURL, err)
59
+ return nil, err
60
+ }
61
+ dataCommittee, err := polygondatacommittee.NewPolygondatacommittee(dataCommitteeAddr, ethClient)
62
+ if err != nil {
63
+ return nil, err
64
+ }
65
+ return &DataCommitteeBackend{
66
+ dataCommitteeContract: dataCommittee,
67
+ privKey: privKey,
68
+ dataCommitteeClientFactory: dataCommitteeClientFactory,
69
+ ctx: context.Background(),
70
+ }, nil
71
+ }
72
+
73
+ // Init loads the DAC to be cached when needed
74
+ func (d *DataCommitteeBackend) Init() error {
75
+ committee, err := d.getCurrentDataCommittee()
76
+ if err != nil {
77
+ return err
78
+ }
79
+ selectedCommitteeMember := -1
80
+ if committee != nil {
81
+ d.committeeMembers = committee.Members
82
+ if len(committee.Members) > 0 {
83
+ selectedCommitteeMember = rand.Intn(len(committee.Members)) //nolint:gosec
84
+ }
85
+ }
86
+ d.selectedCommitteeMember = selectedCommitteeMember
87
+ return nil
88
+ }
89
+
90
+ // GetSequence gets backend data one hash at a time. This should be optimized on the DAC side to get them all at once.
91
+ func (d *DataCommitteeBackend) GetSequence(ctx context.Context, hashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) {
92
+ // TODO: optimize this on the DAC side by implementing a multi batch retrieve api
93
+ var batchData [][]byte
94
+ for _, h := range hashes {
95
+ data, err := d.GetBatchL2Data(h)
96
+ if err != nil {
97
+ return nil, err
98
+ }
99
+ batchData = append(batchData, data)
100
+ }
101
+ return batchData, nil
102
+ }
103
+
104
+ // GetBatchL2Data returns the data from the DAC. It checks that it matches with the expected hash
105
+ func (d *DataCommitteeBackend) GetBatchL2Data(hash common.Hash) ([]byte, error) {
106
+ intialMember := d.selectedCommitteeMember
107
+ found := false
108
+ for !found && intialMember != -1 {
109
+ member := d.committeeMembers[d.selectedCommitteeMember]
110
+ log.Infof("trying to get data from %s at %s", member.Addr.Hex(), member.URL)
111
+ c := d.dataCommitteeClientFactory.New(member.URL)
112
+ data, err := c.GetOffChainData(d.ctx, hash)
113
+ if err != nil {
114
+ log.Warnf(
115
+ "error getting data from DAC node %s at %s: %s",
116
+ member.Addr.Hex(), member.URL, err,
117
+ )
118
+ d.selectedCommitteeMember = (d.selectedCommitteeMember + 1) % len(d.committeeMembers)
119
+ if d.selectedCommitteeMember == intialMember {
120
+ break
121
+ }
122
+ continue
123
+ }
124
+ actualTransactionsHash := crypto.Keccak256Hash(data)
125
+ if actualTransactionsHash != hash {
126
+ unexpectedHash := fmt.Errorf(
127
+ unexpectedHashTemplate, hash, actualTransactionsHash,
128
+ )
129
+ log.Warnf(
130
+ "error getting data from DAC node %s at %s: %s",
131
+ member.Addr.Hex(), member.URL, unexpectedHash,
132
+ )
133
+ d.selectedCommitteeMember = (d.selectedCommitteeMember + 1) % len(d.committeeMembers)
134
+ if d.selectedCommitteeMember == intialMember {
135
+ break
136
+ }
137
+ continue
138
+ }
139
+ return data, nil
140
+ }
141
+ if err := d.Init(); err != nil {
142
+ return nil, fmt.Errorf("error loading data committee: %s", err)
143
+ }
144
+ return nil, fmt.Errorf("couldn't get the data from any committee member")
145
+ }
146
+
147
+ type signatureMsg struct {
148
+ addr common.Address
149
+ signature []byte
150
+ err error
151
+ }
152
+
153
+ // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage
154
+ // as expected by the contract
155
+ func (s *DataCommitteeBackend) PostSequence(ctx context.Context, batchesData [][]byte) ([]byte, error) {
156
+ // Get current committee
157
+ committee, err := s.getCurrentDataCommittee()
158
+ if err != nil {
159
+ return nil, err
160
+ }
161
+
162
+ // Authenticate as trusted sequencer by signing the sequences
163
+ sequence := daTypes.Sequence{}
164
+ for _, seq := range batchesData {
165
+ sequence = append(sequence, seq)
166
+ }
167
+ signedSequence, err := sequence.Sign(s.privKey)
168
+ if err != nil {
169
+ return nil, err
170
+ }
171
+
172
+ // Request signatures to all members in parallel
173
+ ch := make(chan signatureMsg, len(committee.Members))
174
+ signatureCtx, cancelSignatureCollection := context.WithCancel(ctx)
175
+ for _, member := range committee.Members {
176
+ go requestSignatureFromMember(signatureCtx, *signedSequence, member, ch)
177
+ }
178
+
179
+ // Collect signatures
180
+ msgs := []signatureMsg{}
181
+ var (
182
+ collectedSignatures uint64
183
+ failedToCollect uint64
184
+ )
185
+ for collectedSignatures < committee.RequiredSignatures {
186
+ msg := <-ch
187
+ if msg.err != nil {
188
+ log.Errorf("error when trying to get signature from %s: %s", msg.addr, msg.err)
189
+ failedToCollect++
190
+ if len(committee.Members)-int(failedToCollect) < int(committee.RequiredSignatures) {
191
+ cancelSignatureCollection()
192
+ return nil, errors.New("too many members failed to send their signature")
193
+ }
194
+ } else {
195
+ log.Infof("received signature from %s", msg.addr)
196
+ collectedSignatures++
197
+ }
198
+ msgs = append(msgs, msg)
199
+ }
200
+
201
+ // Stop requesting as soon as we have N valid signatures
202
+ cancelSignatureCollection()
203
+
204
+ return buildSignaturesAndAddrs(signatureMsgs(msgs), committee.Members), nil
205
+ }
206
+
207
+ func requestSignatureFromMember(ctx context.Context, signedSequence daTypes.SignedSequence, member DataCommitteeMember, ch chan signatureMsg) {
208
+ // request
209
+ c := client.New(member.URL)
210
+ log.Infof("sending request to sign the sequence to %s at %s", member.Addr.Hex(), member.URL)
211
+ signature, err := c.SignSequence(signedSequence)
212
+ if err != nil {
213
+ ch <- signatureMsg{
214
+ addr: member.Addr,
215
+ err: err,
216
+ }
217
+ return
218
+ }
219
+ // verify returned signature
220
+ signedSequence.Signature = signature
221
+ signer, err := signedSequence.Signer()
222
+ if err != nil {
223
+ ch <- signatureMsg{
224
+ addr: member.Addr,
225
+ err: err,
226
+ }
227
+ return
228
+ }
229
+ if signer != member.Addr {
230
+ ch <- signatureMsg{
231
+ addr: member.Addr,
232
+ err: fmt.Errorf("invalid signer. Expected %s, actual %s", member.Addr.Hex(), signer.Hex()),
233
+ }
234
+ return
235
+ }
236
+ ch <- signatureMsg{
237
+ addr: member.Addr,
238
+ signature: signature,
239
+ }
240
+ }
241
+
242
+ func buildSignaturesAndAddrs(sigs signatureMsgs, members []DataCommitteeMember) []byte {
243
+ const (
244
+ sigLen = 65
245
+ addrLen = 20
246
+ )
247
+ res := make([]byte, 0, len(sigs)*sigLen+len(members)*addrLen)
248
+ sort.Sort(sigs)
249
+ for _, msg := range sigs {
250
+ log.Debugf("adding signature %s from %s", common.Bytes2Hex(msg.signature), msg.addr.Hex())
251
+ res = append(res, msg.signature...)
252
+ }
253
+ for _, member := range members {
254
+ log.Debugf("adding addr %s", common.Bytes2Hex(member.Addr.Bytes()))
255
+ res = append(res, member.Addr.Bytes()...)
256
+ }
257
+ log.Debugf("full res %s", common.Bytes2Hex(res))
258
+ return res
259
+ }
260
+
261
+ type signatureMsgs []signatureMsg
262
+
263
+ func (s signatureMsgs) Len() int { return len(s) }
264
+ func (s signatureMsgs) Less(i, j int) bool {
265
+ return strings.ToUpper(s[i].addr.Hex()) < strings.ToUpper(s[j].addr.Hex())
266
+ }
267
+ func (s signatureMsgs) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
268
+
269
+ // getCurrentDataCommittee return the currently registered data committee
270
+ func (d *DataCommitteeBackend) getCurrentDataCommittee() (*DataCommittee, error) {
271
+ addrsHash, err := d.dataCommitteeContract.CommitteeHash(&bind.CallOpts{Pending: false})
272
+ if err != nil {
273
+ return nil, fmt.Errorf("error getting CommitteeHash from L1 SC: %w", err)
274
+ }
275
+ reqSign, err := d.dataCommitteeContract.RequiredAmountOfSignatures(&bind.CallOpts{Pending: false})
276
+ if err != nil {
277
+ return nil, fmt.Errorf("error getting RequiredAmountOfSignatures from L1 SC: %w", err)
278
+ }
279
+ members, err := d.getCurrentDataCommitteeMembers()
280
+ if err != nil {
281
+ return nil, err
282
+ }
283
+
284
+ return &DataCommittee{
285
+ AddressesHash: common.Hash(addrsHash),
286
+ RequiredSignatures: reqSign.Uint64(),
287
+ Members: members,
288
+ }, nil
289
+ }
290
+
291
+ // getCurrentDataCommitteeMembers return the currently registered data committee members
292
+ func (d *DataCommitteeBackend) getCurrentDataCommitteeMembers() ([]DataCommitteeMember, error) {
293
+ nMembers, err := d.dataCommitteeContract.GetAmountOfMembers(&bind.CallOpts{Pending: false})
294
+ if err != nil {
295
+ return nil, fmt.Errorf("error getting GetAmountOfMembers from L1 SC: %w", err)
296
+ }
297
+ members := make([]DataCommitteeMember, 0, nMembers.Int64())
298
+ for i := int64(0); i < nMembers.Int64(); i++ {
299
+ member, err := d.dataCommitteeContract.Members(&bind.CallOpts{Pending: false}, big.NewInt(i))
300
+ if err != nil {
301
+ return nil, fmt.Errorf("error getting Members %d from L1 SC: %w", i, err)
302
+ }
303
+ members = append(members, DataCommitteeMember{
304
+ Addr: member.Addr,
305
+ URL: member.Url,
306
+ })
307
+ }
308
+ return members, nil
309
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee_test.go RENAMED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package datacommittee
2
+
3
+ import (
4
+ "math/big"
5
+ "testing"
6
+
7
+ "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee"
8
+ "github.com/0xPolygonHermez/zkevm-node/log"
9
+ "github.com/ethereum/go-ethereum/accounts/abi/bind"
10
+ "github.com/ethereum/go-ethereum/common"
11
+ "github.com/ethereum/go-ethereum/core"
12
+ "github.com/ethereum/go-ethereum/crypto"
13
+ "github.com/ethereum/go-ethereum/ethclient/simulated"
14
+ "github.com/stretchr/testify/assert"
15
+ "github.com/stretchr/testify/require"
16
+ )
17
+
18
+ func TestUpdateDataCommitteeEvent(t *testing.T) {
19
+ // Set up testing environment
20
+ dac, ethBackend, auth, da := newTestingEnv(t)
21
+
22
+ // Update the committee
23
+ requiredAmountOfSignatures := big.NewInt(2)
24
+ URLs := []string{"1", "2", "3"}
25
+ addrs := []common.Address{
26
+ common.HexToAddress("0x1"),
27
+ common.HexToAddress("0x2"),
28
+ common.HexToAddress("0x3"),
29
+ }
30
+ addrsBytes := []byte{}
31
+ for _, addr := range addrs {
32
+ addrsBytes = append(addrsBytes, addr.Bytes()...)
33
+ }
34
+ _, err := da.SetupCommittee(auth, requiredAmountOfSignatures, URLs, addrsBytes)
35
+ require.NoError(t, err)
36
+ ethBackend.Commit()
37
+
38
+ // Assert the committee update
39
+ actualSetup, err := dac.getCurrentDataCommittee()
40
+ require.NoError(t, err)
41
+ expectedMembers := []DataCommitteeMember{}
42
+ expectedSetup := DataCommittee{
43
+ RequiredSignatures: uint64(len(URLs) - 1),
44
+ AddressesHash: crypto.Keccak256Hash(addrsBytes),
45
+ }
46
+ for i, url := range URLs {
47
+ expectedMembers = append(expectedMembers, DataCommitteeMember{
48
+ URL: url,
49
+ Addr: addrs[i],
50
+ })
51
+ }
52
+ expectedSetup.Members = expectedMembers
53
+ assert.Equal(t, expectedSetup, *actualSetup)
54
+ }
55
+
56
+ func init() {
57
+ log.Init(log.Config{
58
+ Level: "debug",
59
+ Outputs: []string{"stderr"},
60
+ })
61
+ }
62
+
63
+ // This function prepare the blockchain, the wallet with funds and deploy the smc
64
+ func newTestingEnv(t *testing.T) (
65
+ dac *DataCommitteeBackend,
66
+ ethBackend *simulated.Backend,
67
+ auth *bind.TransactOpts,
68
+ da *polygondatacommittee.Polygondatacommittee,
69
+ ) {
70
+ t.Helper()
71
+ privateKey, err := crypto.GenerateKey()
72
+ if err != nil {
73
+ log.Fatal(err)
74
+ }
75
+ auth, err = bind.NewKeyedTransactorWithChainID(privateKey, big.NewInt(1337))
76
+ if err != nil {
77
+ log.Fatal(err)
78
+ }
79
+ dac, ethBackend, da, err = newSimulatedDacman(t, auth)
80
+ if err != nil {
81
+ log.Fatal(err)
82
+ }
83
+ return dac, ethBackend, auth, da
84
+ }
85
+
86
+ // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
87
+ // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
88
+ func newSimulatedDacman(t *testing.T, auth *bind.TransactOpts) (
89
+ dacman *DataCommitteeBackend,
90
+ ethBackend *simulated.Backend,
91
+ da *polygondatacommittee.Polygondatacommittee,
92
+ err error,
93
+ ) {
94
+ t.Helper()
95
+ if auth == nil {
96
+ // read only client
97
+ return &DataCommitteeBackend{}, nil, nil, nil
98
+ }
99
+ // 10000000 ETH in wei
100
+ balance, _ := new(big.Int).SetString("10000000000000000000000000", 10) //nolint:gomnd
101
+ address := auth.From
102
+ genesisAlloc := map[common.Address]core.GenesisAccount{
103
+ address: {
104
+ Balance: balance,
105
+ },
106
+ }
107
+ blockGasLimit := uint64(999999999999999999) //nolint:gomnd
108
+ client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
109
+
110
+ // DAC Setup
111
+ _, _, da, err = polygondatacommittee.DeployPolygondatacommittee(auth, client.Client())
112
+ if err != nil {
113
+ return &DataCommitteeBackend{}, nil, nil, err
114
+ }
115
+ client.Commit()
116
+ _, err = da.Initialize(auth)
117
+ if err != nil {
118
+ return &DataCommitteeBackend{}, nil, nil, err
119
+ }
120
+ client.Commit()
121
+ _, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{})
122
+ if err != nil {
123
+ return &DataCommitteeBackend{}, nil, nil, err
124
+ }
125
+ client.Commit()
126
+
127
+ c := &DataCommitteeBackend{
128
+ dataCommitteeContract: da,
129
+ }
130
+ return c, client, da, nil
131
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/interfaces.go RENAMED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package dataavailability
2
+
3
+ import (
4
+ "context"
5
+ "math/big"
6
+
7
+ "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
8
+ "github.com/0xPolygonHermez/zkevm-node/state"
9
+ "github.com/ethereum/go-ethereum/common"
10
+ "github.com/jackc/pgx/v4"
11
+ )
12
+
13
+ // DABackender is an interface for components that store and retrieve batch data
14
+ type DABackender interface {
15
+ SequenceRetriever
16
+ SequenceSender
17
+ // Init initializes the DABackend
18
+ Init() error
19
+ }
20
+
21
+ // SequenceSender is used to send provided sequence of batches
22
+ type SequenceSender interface {
23
+ // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage
24
+ // as expected by the contract
25
+ PostSequence(ctx context.Context, batchesData [][]byte) ([]byte, error)
26
+ }
27
+
28
+ // SequenceRetriever is used to retrieve batch data
29
+ type SequenceRetriever interface {
30
+ // GetSequence retrieves the sequence data from the data availability backend
31
+ GetSequence(ctx context.Context, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error)
32
+ }
33
+
34
+ // === Internal interfaces ===
35
+
36
+ type stateInterface interface {
37
+ GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error)
38
+ GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
39
+ GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
40
+ }
41
+
42
+ // BatchDataProvider is used to retrieve batch data
43
+ type BatchDataProvider interface {
44
+ // GetBatchL2Data retrieve the data of a batch from the DA backend. The returned data must be the pre-image of the hash
45
+ GetBatchL2Data(batchNum []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error)
46
+ }
47
+
48
+ // DataManager is an interface for components that send and retrieve batch data
49
+ type DataManager interface {
50
+ BatchDataProvider
51
+ SequenceSender
52
+ }
53
+
54
+ // ZKEVMClientTrustedBatchesGetter contains the methods required to interact with zkEVM-RPC
55
+ type ZKEVMClientTrustedBatchesGetter interface {
56
+ BatchByNumber(ctx context.Context, number *big.Int) (*types.Batch, error)
57
+ BatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error)
58
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/pool/validium-001.sql RENAMED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -- +migrate Down
2
+ DROP TABLE IF EXISTS pool.acl CASCADE;
3
+ DROP TABLE IF EXISTS pool.policy CASCADE;
4
+
5
+ -- +migrate Up
6
+ CREATE TABLE pool.policy
7
+ (
8
+ name VARCHAR PRIMARY KEY,
9
+ allow BOOLEAN NOT NULL DEFAULT false
10
+ );
11
+
12
+ INSERT INTO pool.policy (name, allow) VALUES ('send_tx', false);
13
+ INSERT INTO pool.policy (name, allow) VALUES ('deploy', false);
14
+
15
+ CREATE TABLE pool.acl
16
+ (
17
+ address VARCHAR,
18
+ policy VARCHAR,
19
+ PRIMARY KEY (address, policy)
20
+ );
{/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0017.sql RENAMED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ -- +migrate Up
2
+ ALTER TABLE state.receipt
3
+ ADD COLUMN IF NOT EXISTS im_state_root BYTEA;
4
+
5
+ UPDATE state.receipt SET im_state_root = post_state WHERE block_num >= (SELECT MIN(block_num) FROM state.l2block WHERE batch_num >= (SELECT from_batch_num FROM state.fork_id WHERE fork_id = 7));
6
+
7
+ -- +migrate Down
8
+ ALTER TABLE state.receipt
9
+ DROP COLUMN IF EXISTS im_state_root;
{/home/stefan/go/src/Polygon/zkevm-node → .}/diffgen.sh RENAMED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PATH_TO_ZKEVM_NODE_REPO="/home/stefan/go/src/Polygon/zkevm-node/"
2
+ diff -ruN \
3
+ -I ".*github.com\/0x.*" \
4
+ -x "*mock*" -x ".git" \
5
+ -x ".github" \
6
+ -x ".gitignore" \
7
+ -x ".vscode" \
8
+ -x "ci" \
9
+ -x "environments" \
10
+ -x "*.md" \
11
+ -x "*.html" \
12
+ -x "*.html" \
13
+ -x "*.json" \
14
+ -x "*.toml" \
15
+ -x "*.abi" \
16
+ -x "*.bin" \
17
+ -x "*.pb.go" \
18
+ -x "smartcontracts" \
19
+ -x "go.sum" \
20
+ -x "mock*.go" \
21
+ -x "*venv*" \
22
+ -x "/dist/" \
23
+ -x "/test/e2e/keystore" \
24
+ -x "/test/vectors/src/**/*md" \
25
+ -x "/test/vectors/src/**/*js" \
26
+ -x "/test/vectors/src/**/*sol" \
27
+ -x "/test/vectors/src/**/*sh" \
28
+ -x "/test/vectors/src/package.json" \
29
+ -x "/test/contracts/bin/**/*.bin" \
30
+ -x "/test/contracts/bin/**/*.abi" \
31
+ -x "/tools/datastreamer/*.bin" \
32
+ -x "/test/datastreamer/*.db/*" \
33
+ -x "/test/*.bin" \
34
+ -x "/test/*.db/*" \
35
+ -x "**/.DS_Store" \
36
+ -x ".vscode" \
37
+ -x ".idea/" \
38
+ -x ".env" \
39
+ -x "out.dat" \
40
+ -x "cmd/__debug_bin" \
41
+ -x ".venv" \
42
+ -x "*metrics.txt" \
43
+ -x "coverage.out" \
44
+ -x "*datastream.db*" \
45
+ ${PATH_TO_ZKEVM_NODE_REPO} . | \
46
+ diff2html -i stdin -s side -t "zkEVM node vs CDK validium node</br><h2>zkevm-node version: v0.6.0<h2/>" \
47
+ -F ./docs/diff/diff.html
{/home/stefan/go/src/Polygon/zkevm-node → .}/docker-compose.yml RENAMED
@@ -107,7 +107,7 @@
107
  zkevm-prover:
108
  container_name: zkevm-prover
109
  restart: unless-stopped
110
- image: hermeznetwork/zkevm-prover:v5.0.3
111
  depends_on:
112
  zkevm-state-db:
113
  condition: service_healthy
 
107
  zkevm-prover:
108
  container_name: zkevm-prover
109
  restart: unless-stopped
110
+ image: hermeznetwork/zkevm-prover:v6.0.0
111
  depends_on:
112
  zkevm-state-db:
113
  condition: service_healthy
{/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile RENAMED
@@ -14,7 +14,6 @@
14
  # CONTAINER FOR RUNNING BINARY
15
  FROM alpine:3.18
16
  COPY --from=build /src/dist/zkevm-node /app/zkevm-node
17
- COPY --from=build /src/config/environments/testnet/node.config.toml /app/example.config.toml
18
  RUN apk update && apk add postgresql15-client
19
  EXPOSE 8123
20
  CMD ["/bin/sh", "-c", "/app/zkevm-node run"]
 
14
  # CONTAINER FOR RUNNING BINARY
15
  FROM alpine:3.18
16
  COPY --from=build /src/dist/zkevm-node /app/zkevm-node
 
17
  RUN apk update && apk add postgresql15-client
18
  EXPOSE 8123
19
  CMD ["/bin/sh", "-c", "/app/zkevm-node run"]
{/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile.release RENAMED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM alpine:3.18
2
+
3
+ COPY zkevm-node /app/zkevm-node
4
+
5
+ EXPOSE 8123
6
+
7
+ RUN addgroup -S zkevm-group \
8
+ && adduser -S zkevm-user -G zkevm-group
9
+
10
+ RUN chown -R zkevm-user:zkevm-group /app
11
+
12
+ USER zkevm-user
13
+
14
+ CMD ["/app/zkevm-node"]
15
+
{/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman.go RENAMED
@@ -3,6 +3,7 @@
3
  import (
4
  "bytes"
5
  "context"
 
6
  "encoding/json"
7
  "errors"
8
  "fmt"
@@ -106,6 +109,11 @@
106
  // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry
107
  methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address)
108
 
 
 
 
 
 
109
  // ErrNotFound is used when the object is not found
110
  ErrNotFound = errors.New("not found")
111
  // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode.
@@ -189,6 +197,7 @@
189
  GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
190
  OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot
191
  Pol *pol.Pol
 
192
  SCAddresses []common.Address
193
 
194
  RollupID uint32
@@ -198,10 +207,12 @@
198
  l1Cfg L1Config
199
  cfg Config
200
  auth map[common.Address]bind.TransactOpts // empty in case of read-only client
 
 
201
  }
202
 
203
  // NewClient creates a new etherman.
204
- func NewClient(cfg Config, l1Config L1Config) (*Client, error) {
205
  // Connect to ethereum node
206
  ethClient, err := ethclient.Dial(cfg.URL)
207
  if err != nil {
@@ -244,6 +255,14 @@
244
  log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err)
245
  return nil, err
246
  }
 
 
 
 
 
 
 
 
247
  var scAddresses []common.Address
248
  scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr)
249
 
@@ -274,6 +293,7 @@
274
  RollupManager: rollupManager,
275
  Pol: pol,
276
  GlobalExitRootManager: globalExitRoot,
 
277
  OldGlobalExitRootManager: oldGlobalExitRoot,
278
  SCAddresses: scAddresses,
279
  RollupID: rollupID,
@@ -284,11 +304,13 @@
284
  l1Cfg: l1Config,
285
  cfg: cfg,
286
  auth: map[common.Address]bind.TransactOpts{},
 
287
  }, nil
288
  }
289
 
290
  // VerifyGenBlockNumber verifies if the genesis Block Number is valid
291
  func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) {
 
292
  start := time.Now()
293
  log.Info("Verifying genesis blockNumber: ", genBlockNumber)
294
  // Filter query
@@ -344,6 +366,11 @@
344
  log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber)
345
  start := time.Now()
346
  var logs []types.Log
 
 
 
 
 
347
  log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize)
348
  for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 {
349
  final := i + etherMan.cfg.ForkIDChunkSize
@@ -684,61 +711,8 @@
684
  return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID)
685
  }
686
 
687
- func (etherMan *Client) updateEtrogSequence(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
688
- log.Debug("updateEtrogSequence event detected")
689
- updateEtrogSequence, err := etherMan.EtrogZKEVM.ParseUpdateEtrogSequence(vLog)
690
- if err != nil {
691
- log.Error("error parsing updateEtrogSequence event. Error: ", err)
692
- return err
693
- }
694
-
695
- // Read the tx for this event.
696
- tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex)
697
- if err != nil {
698
- return err
699
- }
700
- if tx.Hash() != vLog.TxHash {
701
- return fmt.Errorf("error: tx hash mismatch. want: %s have: %s", vLog.TxHash, tx.Hash().String())
702
- }
703
- msg, err := core.TransactionToMessage(tx, types.NewLondonSigner(tx.ChainId()), big.NewInt(0))
704
- if err != nil {
705
- return err
706
- }
707
- fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash)
708
- if err != nil {
709
- return fmt.Errorf("error getting fullBlockInfo. BlockNumber: %d. Error: %w", vLog.BlockNumber, err)
710
- }
711
-
712
- log.Info("update Etrog transaction sequence...")
713
- sequence := UpdateEtrogSequence{
714
- BatchNumber: updateEtrogSequence.NumBatch,
715
- SequencerAddr: updateEtrogSequence.Sequencer,
716
- TxHash: vLog.TxHash,
717
- Nonce: msg.Nonce,
718
- PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{
719
- Transactions: updateEtrogSequence.Transactions,
720
- ForcedGlobalExitRoot: updateEtrogSequence.LastGlobalExitRoot,
721
- ForcedTimestamp: fullBlock.Time(),
722
- ForcedBlockHashL1: fullBlock.ParentHash(),
723
- },
724
- }
725
-
726
- if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) {
727
- block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock)
728
- block.UpdateEtrogSequence = sequence
729
- *blocks = append(*blocks, block)
730
- } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber {
731
- (*blocks)[len(*blocks)-1].UpdateEtrogSequence = sequence
732
- } else {
733
- log.Error("Error processing UpdateEtrogSequence event. BlockHash:", vLog.BlockHash, ". BlockNumber: ", vLog.BlockNumber)
734
- return fmt.Errorf("error processing UpdateEtrogSequence event")
735
- }
736
- or := Order{
737
- Name: UpdateEtrogSequenceOrder,
738
- Pos: 0,
739
- }
740
- (*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash] = append((*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash], or)
741
- return nil
742
  }
743
 
744
  func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
@@ -937,14 +911,14 @@
937
  }
938
 
939
  // EstimateGasSequenceBatches estimates gas for sending batches
940
- func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) {
941
  opts, err := etherMan.getAuthByAddress(sender)
942
  if err == ErrNotFound {
943
  return nil, ErrPrivateKeyNotFound
944
  }
945
  opts.NoSend = true
946
 
947
- tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
948
  if err != nil {
949
  return nil, err
950
  }
@@ -953,7 +927,7 @@
953
  }
954
 
955
  // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches.
956
- func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error) {
957
  opts, err := etherMan.getAuthByAddress(sender)
958
  if err == ErrNotFound {
959
  return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound)
@@ -964,7 +938,7 @@
964
  opts.GasLimit = uint64(1)
965
  opts.GasPrice = big.NewInt(1)
966
 
967
- tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
968
  if err != nil {
969
  return nil, nil, err
970
  }
@@ -972,15 +946,15 @@
972
  return tx.To(), tx.Data(), nil
973
  }
974
 
975
- func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) {
976
- var batches []polygonzkevm.PolygonRollupBaseEtrogBatchData
977
  for _, seq := range sequences {
978
  var ger common.Hash
979
  if seq.ForcedBatchTimestamp > 0 {
980
  ger = seq.GlobalExitRoot
981
  }
982
- batch := polygonzkevm.PolygonRollupBaseEtrogBatchData{
983
- Transactions: seq.BatchL2Data,
984
  ForcedGlobalExitRoot: ger,
985
  ForcedTimestamp: uint64(seq.ForcedBatchTimestamp),
986
  ForcedBlockHashL1: seq.PrevBlockHash,
@@ -989,7 +963,7 @@
989
  batches = append(batches, batch)
990
  }
991
 
992
- tx, err := etherMan.ZkEVM.SequenceBatches(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
993
  if err != nil {
994
  log.Debugf("Batches to send: %+v", batches)
995
  log.Debug("l2CoinBase: ", l2Coinbase)
@@ -1209,13 +1183,15 @@
1209
  if sb.NumBatch != 1 {
1210
  methodId := tx.Data()[:4]
1211
  log.Debugf("MethodId: %s", common.Bytes2Hex(methodId))
1212
- if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) {
1213
- sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot)
 
1214
  if err != nil {
1215
  return fmt.Errorf("error decoding the sequences (etrog): %v", err)
1216
  }
1217
- } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) {
1218
- sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot)
 
1219
  if err != nil {
1220
  return fmt.Errorf("error decoding the sequences (elderberry): %v", err)
1221
  }
@@ -1301,7 +1277,7 @@
1301
  return nil
1302
  }
1303
 
1304
- func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) {
1305
  // Extract coded txs.
1306
  // Load contract ABI
1307
  smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
@@ -1309,54 +1285,11 @@
1309
  return nil, err
1310
  }
1311
 
1312
- // Recover Method from signature and ABI
1313
- method, err := smcAbi.MethodById(txData[:4])
1314
- if err != nil {
1315
- return nil, err
1316
- }
1317
-
1318
- // Unpack method inputs
1319
- data, err := method.Inputs.Unpack(txData[4:])
1320
- if err != nil {
1321
- return nil, err
1322
- }
1323
- var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
1324
- bytedata, err := json.Marshal(data[0])
1325
- if err != nil {
1326
- return nil, err
1327
- }
1328
- err = json.Unmarshal(bytedata, &sequences)
1329
- if err != nil {
1330
- return nil, err
1331
- }
1332
- maxSequenceTimestamp := data[1].(uint64)
1333
- initSequencedBatchNumber := data[2].(uint64)
1334
- coinbase := (data[3]).(common.Address)
1335
- sequencedBatches := make([]SequencedBatch, len(sequences))
1336
-
1337
- for i, seq := range sequences {
1338
- elderberry := SequencedBatchElderberryData{
1339
- MaxSequenceTimestamp: maxSequenceTimestamp,
1340
- InitSequencedBatchNumber: initSequencedBatchNumber,
1341
- }
1342
- bn := lastBatchNumber - uint64(len(sequences)-(i+1))
1343
- s := seq
1344
- sequencedBatches[i] = SequencedBatch{
1345
- BatchNumber: bn,
1346
- L1InfoRoot: &l1InfoRoot,
1347
- SequencerAddr: sequencer,
1348
- TxHash: txHash,
1349
- Nonce: nonce,
1350
- Coinbase: coinbase,
1351
- PolygonRollupBaseEtrogBatchData: &s,
1352
- SequencedBatchElderberryData: &elderberry,
1353
- }
1354
- }
1355
-
1356
- return sequencedBatches, nil
1357
  }
1358
 
1359
- func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) {
 
1360
  // Extract coded txs.
1361
  // Load contract ABI
1362
  smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
@@ -1364,6 +1297,13 @@
1364
  return nil, err
1365
  }
1366
 
 
 
 
 
 
 
 
1367
  // Recover Method from signature and ABI
1368
  method, err := smcAbi.MethodById(txData[:4])
1369
  if err != nil {
@@ -1375,32 +1315,123 @@
1375
  if err != nil {
1376
  return nil, err
1377
  }
1378
- var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
1379
  bytedata, err := json.Marshal(data[0])
1380
  if err != nil {
1381
  return nil, err
1382
  }
1383
- err = json.Unmarshal(bytedata, &sequences)
1384
- if err != nil {
1385
- return nil, err
1386
- }
1387
- coinbase := (data[1]).(common.Address)
1388
- sequencedBatches := make([]SequencedBatch, len(sequences))
1389
- for i, seq := range sequences {
1390
- bn := lastBatchNumber - uint64(len(sequences)-(i+1))
1391
- s := seq
1392
- sequencedBatches[i] = SequencedBatch{
1393
- BatchNumber: bn,
1394
- L1InfoRoot: &l1InfoRoot,
1395
- SequencerAddr: sequencer,
1396
- TxHash: txHash,
1397
- Nonce: nonce,
1398
- Coinbase: coinbase,
1399
- PolygonRollupBaseEtrogBatchData: &s,
1400
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1401
  }
1402
 
1403
- return sequencedBatches, nil
1404
  }
1405
 
1406
  func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) {
@@ -1872,15 +1903,15 @@
1872
  }
1873
 
1874
  // LoadAuthFromKeyStore loads an authorization from a key store file
1875
- func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, error) {
1876
- auth, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID)
1877
  if err != nil {
1878
- return nil, err
1879
  }
1880
 
1881
  log.Infof("loaded authorization for address: %v", auth.From.String())
1882
  etherMan.auth[auth.From] = auth
1883
- return &auth, nil
1884
  }
1885
 
1886
  // newKeyFromKeystore creates an instance of a keystore key from a keystore file
@@ -1901,20 +1932,20 @@
1901
  }
1902
 
1903
  // newAuthFromKeystore an authorization instance from a keystore file
1904
- func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, error) {
1905
  log.Infof("reading key from: %v", path)
1906
  key, err := newKeyFromKeystore(path, password)
1907
  if err != nil {
1908
- return bind.TransactOpts{}, err
1909
  }
1910
  if key == nil {
1911
- return bind.TransactOpts{}, nil
1912
  }
1913
  auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID))
1914
  if err != nil {
1915
- return bind.TransactOpts{}, err
1916
  }
1917
- return *auth, nil
1918
  }
1919
 
1920
  // getAuthByAddress tries to get an authorization from the authorizations map
@@ -1942,3 +1973,28 @@
1942
 
1943
  return *auth, nil
1944
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  import (
4
  "bytes"
5
  "context"
6
+ "crypto/ecdsa"
7
  "encoding/json"
8
  "errors"
9
  "fmt"
 
109
  // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry
110
  methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address)
111
 
112
+ // methodIDSequenceBatchesValidiumEtrog: MethodID for sequenceBatchesValidium in Etrog
113
+ methodIDSequenceBatchesValidiumEtrog = []byte{0x2d, 0x72, 0xc2, 0x48} // 0x2d72c248 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],address,bytes)
114
+ // methodIDSequenceBatchesValidiumElderberry: MethodID for sequenceBatchesValidium in Elderberry
115
+ methodIDSequenceBatchesValidiumElderberry = []byte{0xdb, 0x5b, 0x0e, 0xd7} // 0xdb5b0ed7 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint64,uint64,address,bytes)
116
+
117
  // ErrNotFound is used when the object is not found
118
  ErrNotFound = errors.New("not found")
119
  // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode.
 
197
  GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
198
  OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot
199
  Pol *pol.Pol
200
+ DAProtocol *dataavailabilityprotocol.Dataavailabilityprotocol
201
  SCAddresses []common.Address
202
 
203
  RollupID uint32
 
207
  l1Cfg L1Config
208
  cfg Config
209
  auth map[common.Address]bind.TransactOpts // empty in case of read-only client
210
+
211
+ da dataavailability.BatchDataProvider
212
  }
213
 
214
  // NewClient creates a new etherman.
215
+ func NewClient(cfg Config, l1Config L1Config, da dataavailability.BatchDataProvider) (*Client, error) {
216
  // Connect to ethereum node
217
  ethClient, err := ethclient.Dial(cfg.URL)
218
  if err != nil {
 
255
  log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err)
256
  return nil, err
257
  }
258
+ dapAddr, err := zkevm.DataAvailabilityProtocol(&bind.CallOpts{Pending: false})
259
+ if err != nil {
260
+ return nil, err
261
+ }
262
+ dap, err := dataavailabilityprotocol.NewDataavailabilityprotocol(dapAddr, ethClient)
263
+ if err != nil {
264
+ return nil, err
265
+ }
266
  var scAddresses []common.Address
267
  scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr)
268
 
 
293
  RollupManager: rollupManager,
294
  Pol: pol,
295
  GlobalExitRootManager: globalExitRoot,
296
+ DAProtocol: dap,
297
  OldGlobalExitRootManager: oldGlobalExitRoot,
298
  SCAddresses: scAddresses,
299
  RollupID: rollupID,
 
304
  l1Cfg: l1Config,
305
  cfg: cfg,
306
  auth: map[common.Address]bind.TransactOpts{},
307
+ da: da,
308
  }, nil
309
  }
310
 
311
  // VerifyGenBlockNumber verifies if the genesis Block Number is valid
312
  func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) {
313
+ // TODO: do not assume that only one rollup will be attached to the rollup manager in the same L1 block
314
  start := time.Now()
315
  log.Info("Verifying genesis blockNumber: ", genBlockNumber)
316
  // Filter query
 
366
  log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber)
367
  start := time.Now()
368
  var logs []types.Log
369
+
370
+ if lastL1BlockSynced < genBlockNumber {
371
+ lastL1BlockSynced = genBlockNumber
372
+ }
373
+
374
  log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize)
375
  for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 {
376
  final := i + etherMan.cfg.ForkIDChunkSize
 
711
  return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID)
712
  }
713
 
714
+ func (etherMan *Client) updateEtrogSequence(_ context.Context, _ types.Log, _ *[]Block, _ *map[common.Hash][]Order) error {
715
+ return errors.New("upgrading validiums to etrog not supported")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
716
  }
717
 
718
  func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
 
911
  }
912
 
913
  // EstimateGasSequenceBatches estimates gas for sending batches
914
+ func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) {
915
  opts, err := etherMan.getAuthByAddress(sender)
916
  if err == ErrNotFound {
917
  return nil, ErrPrivateKeyNotFound
918
  }
919
  opts.NoSend = true
920
 
921
+ tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
922
  if err != nil {
923
  return nil, err
924
  }
 
927
  }
928
 
929
  // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches.
930
+ func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (to *common.Address, data []byte, err error) {
931
  opts, err := etherMan.getAuthByAddress(sender)
932
  if err == ErrNotFound {
933
  return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound)
 
938
  opts.GasLimit = uint64(1)
939
  opts.GasPrice = big.NewInt(1)
940
 
941
+ tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
942
  if err != nil {
943
  return nil, nil, err
944
  }
 
946
  return tx.To(), tx.Data(), nil
947
  }
948
 
949
+ func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) {
950
+ var batches []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
951
  for _, seq := range sequences {
952
  var ger common.Hash
953
  if seq.ForcedBatchTimestamp > 0 {
954
  ger = seq.GlobalExitRoot
955
  }
956
+ batch := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
957
+ TransactionsHash: crypto.Keccak256Hash(seq.BatchL2Data),
958
  ForcedGlobalExitRoot: ger,
959
  ForcedTimestamp: uint64(seq.ForcedBatchTimestamp),
960
  ForcedBlockHashL1: seq.PrevBlockHash,
 
963
  batches = append(batches, batch)
964
  }
965
 
966
+ tx, err := etherMan.ZkEVM.SequenceBatchesValidium(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
967
  if err != nil {
968
  log.Debugf("Batches to send: %+v", batches)
969
  log.Debug("l2CoinBase: ", l2Coinbase)
 
1183
  if sb.NumBatch != 1 {
1184
  methodId := tx.Data()[:4]
1185
  log.Debugf("MethodId: %s", common.Bytes2Hex(methodId))
1186
+ if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) ||
1187
+ bytes.Equal(methodId, methodIDSequenceBatchesValidiumEtrog) {
1188
+ sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da)
1189
  if err != nil {
1190
  return fmt.Errorf("error decoding the sequences (etrog): %v", err)
1191
  }
1192
+ } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) ||
1193
+ bytes.Equal(methodId, methodIDSequenceBatchesValidiumElderberry) {
1194
+ sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da)
1195
  if err != nil {
1196
  return fmt.Errorf("error decoding the sequences (elderberry): %v", err)
1197
  }
 
1277
  return nil
1278
  }
1279
 
1280
+ func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash, da dataavailability.BatchDataProvider) ([]SequencedBatch, error) {
1281
  // Extract coded txs.
1282
  // Load contract ABI
1283
  smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
 
1285
  return nil, err
1286
  }
1287
 
1288
+ return decodeSequencedBatches(smcAbi, txData, state.FORKID_ELDERBERRY, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1289
  }
1290
 
1291
+ func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash,
1292
+ da dataavailability.BatchDataProvider) ([]SequencedBatch, error) {
1293
  // Extract coded txs.
1294
  // Load contract ABI
1295
  smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
 
1297
  return nil, err
1298
  }
1299
 
1300
+ return decodeSequencedBatches(smcAbi, txData, state.FORKID_ETROG, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da)
1301
+ }
1302
+
1303
+ // decodeSequencedBatches decodes provided data, based on the funcName, whether it is rollup or validium data and returns sequenced batches
1304
+ func decodeSequencedBatches(smcAbi abi.ABI, txData []byte, forkID uint64, lastBatchNumber uint64,
1305
+ sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash,
1306
+ da dataavailability.BatchDataProvider) ([]SequencedBatch, error) {
1307
  // Recover Method from signature and ABI
1308
  method, err := smcAbi.MethodById(txData[:4])
1309
  if err != nil {
 
1315
  if err != nil {
1316
  return nil, err
1317
  }
 
1318
  bytedata, err := json.Marshal(data[0])
1319
  if err != nil {
1320
  return nil, err
1321
  }
1322
+
1323
+ var (
1324
+ maxSequenceTimestamp uint64
1325
+ initSequencedBatchNumber uint64
1326
+ coinbase common.Address
1327
+ dataAvailabilityMsg []byte
1328
+ )
1329
+
1330
+ switch method.Name {
1331
+ case "sequenceBatches":
1332
+ var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
1333
+ err := json.Unmarshal(bytedata, &sequences)
1334
+ if err != nil {
1335
+ return nil, err
 
 
 
1336
  }
1337
+
1338
+ switch forkID {
1339
+ case state.FORKID_ETROG:
1340
+ coinbase = data[1].(common.Address)
1341
+
1342
+ case state.FORKID_ELDERBERRY:
1343
+ maxSequenceTimestamp = data[1].(uint64)
1344
+ initSequencedBatchNumber = data[2].(uint64)
1345
+ coinbase = data[3].(common.Address)
1346
+ }
1347
+
1348
+ sequencedBatches := make([]SequencedBatch, len(sequences))
1349
+ for i, seq := range sequences {
1350
+ bn := lastBatchNumber - uint64(len(sequences)-(i+1))
1351
+ s := seq
1352
+ batch := SequencedBatch{
1353
+ BatchNumber: bn,
1354
+ L1InfoRoot: &l1InfoRoot,
1355
+ SequencerAddr: sequencer,
1356
+ TxHash: txHash,
1357
+ Nonce: nonce,
1358
+ Coinbase: coinbase,
1359
+ PolygonRollupBaseEtrogBatchData: &s,
1360
+ }
1361
+ if forkID >= state.FORKID_ELDERBERRY {
1362
+ batch.SequencedBatchElderberryData = &SequencedBatchElderberryData{
1363
+ MaxSequenceTimestamp: maxSequenceTimestamp,
1364
+ InitSequencedBatchNumber: initSequencedBatchNumber,
1365
+ }
1366
+ }
1367
+ sequencedBatches[i] = batch
1368
+ }
1369
+
1370
+ return sequencedBatches, nil
1371
+ case "sequenceBatchesValidium":
1372
+ var sequencesValidium []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
1373
+ err := json.Unmarshal(bytedata, &sequencesValidium)
1374
+ if err != nil {
1375
+ return nil, err
1376
+ }
1377
+
1378
+ switch forkID {
1379
+ case state.FORKID_ETROG:
1380
+ coinbase = data[1].(common.Address)
1381
+ dataAvailabilityMsg = data[2].([]byte)
1382
+
1383
+ case state.FORKID_ELDERBERRY:
1384
+ maxSequenceTimestamp = data[1].(uint64)
1385
+ initSequencedBatchNumber = data[2].(uint64)
1386
+ coinbase = data[3].(common.Address)
1387
+ dataAvailabilityMsg = data[4].([]byte)
1388
+ }
1389
+
1390
+ sequencedBatches := make([]SequencedBatch, len(sequencesValidium))
1391
+
1392
+ var (
1393
+ batchNums []uint64
1394
+ hashes []common.Hash
1395
+ )
1396
+
1397
+ for i, validiumData := range sequencesValidium {
1398
+ bn := lastBatchNumber - uint64(len(sequencesValidium)-(i+1))
1399
+ batchNums = append(batchNums, bn)
1400
+ hashes = append(hashes, validiumData.TransactionsHash)
1401
+ }
1402
+ batchL2Data, err := da.GetBatchL2Data(batchNums, hashes, dataAvailabilityMsg)
1403
+ if err != nil {
1404
+ return nil, err
1405
+ }
1406
+ for i, bn := range batchNums {
1407
+ s := polygonzkevm.PolygonRollupBaseEtrogBatchData{
1408
+ Transactions: batchL2Data[i],
1409
+ ForcedGlobalExitRoot: sequencesValidium[i].ForcedGlobalExitRoot,
1410
+ ForcedTimestamp: sequencesValidium[i].ForcedTimestamp,
1411
+ ForcedBlockHashL1: sequencesValidium[i].ForcedBlockHashL1,
1412
+ }
1413
+ batch := SequencedBatch{
1414
+ BatchNumber: bn,
1415
+ L1InfoRoot: &l1InfoRoot,
1416
+ SequencerAddr: sequencer,
1417
+ TxHash: txHash,
1418
+ Nonce: nonce,
1419
+ Coinbase: coinbase,
1420
+ PolygonRollupBaseEtrogBatchData: &s,
1421
+ }
1422
+ if forkID >= state.FORKID_ELDERBERRY {
1423
+ elderberry := &SequencedBatchElderberryData{
1424
+ MaxSequenceTimestamp: maxSequenceTimestamp,
1425
+ InitSequencedBatchNumber: initSequencedBatchNumber,
1426
+ }
1427
+ batch.SequencedBatchElderberryData = elderberry
1428
+ }
1429
+ sequencedBatches[i] = batch
1430
+ }
1431
+ return sequencedBatches, nil
1432
  }
1433
 
1434
+ return nil, fmt.Errorf("unexpected method called in sequence batches transaction: %s", method.RawName)
1435
  }
1436
 
1437
  func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) {
 
1903
  }
1904
 
1905
  // LoadAuthFromKeyStore loads an authorization from a key store file
1906
+ func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, *ecdsa.PrivateKey, error) {
1907
+ auth, pk, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID)
1908
  if err != nil {
1909
+ return nil, nil, err
1910
  }
1911
 
1912
  log.Infof("loaded authorization for address: %v", auth.From.String())
1913
  etherMan.auth[auth.From] = auth
1914
+ return &auth, pk, nil
1915
  }
1916
 
1917
  // newKeyFromKeystore creates an instance of a keystore key from a keystore file
 
1932
  }
1933
 
1934
  // newAuthFromKeystore an authorization instance from a keystore file
1935
+ func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, *ecdsa.PrivateKey, error) {
1936
  log.Infof("reading key from: %v", path)
1937
  key, err := newKeyFromKeystore(path, password)
1938
  if err != nil {
1939
+ return bind.TransactOpts{}, nil, err
1940
  }
1941
  if key == nil {
1942
+ return bind.TransactOpts{}, nil, nil
1943
  }
1944
  auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID))
1945
  if err != nil {
1946
+ return bind.TransactOpts{}, nil, err
1947
  }
1948
+ return *auth, key.PrivateKey, nil
1949
  }
1950
 
1951
  // getAuthByAddress tries to get an authorization from the authorizations map
 
1973
 
1974
  return *auth, nil
1975
  }
1976
+
1977
+ // GetDAProtocolAddr returns the address of the data availability protocol
1978
+ func (etherMan *Client) GetDAProtocolAddr() (common.Address, error) {
1979
+ return etherMan.ZkEVM.DataAvailabilityProtocol(&bind.CallOpts{Pending: false})
1980
+ }
1981
+
1982
+ // GetDAProtocolName returns the name of the data availability protocol
1983
+ func (etherMan *Client) GetDAProtocolName() (string, error) {
1984
+ return etherMan.DAProtocol.GetProcotolName(&bind.CallOpts{Pending: false})
1985
+ }
1986
+
1987
+ // SetDataAvailabilityProtocol sets the address for the new data availability protocol
1988
+ func (etherMan *Client) SetDataAvailabilityProtocol(from, daAddress common.Address) (*types.Transaction, error) {
1989
+ auth, err := etherMan.getAuthByAddress(from)
1990
+ if err != nil {
1991
+ return nil, err
1992
+ }
1993
+
1994
+ return etherMan.ZkEVM.SetDataAvailabilityProtocol(&auth, daAddress)
1995
+ }
1996
+
1997
+ // GetRollupId returns the rollup id
1998
+ func (etherMan *Client) GetRollupId() uint32 {
1999
+ return etherMan.RollupID
2000
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go RENAMED
@@ -38,7 +38,7 @@
38
  }
39
 
40
  // This function prepare the blockchain, the wallet with funds and deploy the smc
41
- func newTestingEnv() (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge) {
42
  privateKey, err := crypto.GenerateKey()
43
  if err != nil {
44
  log.Fatal(err)
@@ -47,7 +47,8 @@
47
  if err != nil {
48
  log.Fatal(err)
49
  }
50
- ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth)
 
51
  if err != nil {
52
  log.Fatal(err)
53
  }
@@ -55,12 +56,12 @@
55
  if err != nil {
56
  log.Fatal(err)
57
  }
58
- return ethman, ethBackend, auth, polAddr, br
59
  }
60
 
61
  func TestGEREvent(t *testing.T) {
62
  // Set up testing environment
63
- etherman, ethBackend, auth, _, br := newTestingEnv()
64
 
65
  // Read currentBlock
66
  ctx := context.Background()
@@ -82,14 +83,14 @@
82
  blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
83
  require.NoError(t, err)
84
  t.Logf("Blocks: %+v", blocks)
85
- assert.Equal(t, uint64(8), blocks[0].L1InfoTree[0].BlockNumber)
86
  assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot)
87
  assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot)
88
  }
89
 
90
  func TestForcedBatchEvent(t *testing.T) {
91
  // Set up testing environment
92
- etherman, ethBackend, auth, _, _ := newTestingEnv()
93
 
94
  // Read currentBlock
95
  ctx := context.Background()
@@ -114,8 +115,8 @@
114
  blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
115
  require.NoError(t, err)
116
  t.Logf("Blocks: %+v", blocks)
117
- assert.Equal(t, uint64(8), blocks[0].BlockNumber)
118
- assert.Equal(t, uint64(8), blocks[0].ForcedBatches[0].BlockNumber)
119
  assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot)
120
  assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt)
121
  assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber)
@@ -125,7 +126,7 @@
125
 
126
  func TestSequencedBatchesEvent(t *testing.T) {
127
  // Set up testing environment
128
- etherman, ethBackend, auth, _, br := newTestingEnv()
129
 
130
  // Read currentBlock
131
  ctx := context.Background()
@@ -156,13 +157,19 @@
156
  blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber)
157
  require.NoError(t, err)
158
  t.Log("Blocks: ", blocks)
159
- var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
160
- sequences = append(sequences, polygonzkevm.PolygonRollupBaseEtrogBatchData{
161
- Transactions: common.Hex2Bytes(rawTxs),
162
- }, polygonzkevm.PolygonRollupBaseEtrogBatchData{
163
- Transactions: common.Hex2Bytes(rawTxs),
 
164
  })
165
- _, err = etherman.ZkEVM.SequenceBatches(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From)
 
 
 
 
 
166
  require.NoError(t, err)
167
 
168
  // Mine the tx in a block
@@ -188,7 +195,7 @@
188
 
189
  func TestVerifyBatchEvent(t *testing.T) {
190
  // Set up testing environment
191
- etherman, ethBackend, auth, _, _ := newTestingEnv()
192
 
193
  // Read currentBlock
194
  ctx := context.Background()
@@ -197,12 +204,13 @@
197
  require.NoError(t, err)
198
 
199
  rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
200
- tx := polygonzkevm.PolygonRollupBaseEtrogBatchData{
201
- Transactions: common.Hex2Bytes(rawTxs),
202
  }
203
- //TODO: Fix params
204
- _, err = etherman.ZkEVM.SequenceBatches(auth, []polygonzkevm.PolygonRollupBaseEtrogBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From)
205
  require.NoError(t, err)
 
206
 
207
  // Mine the tx in a block
208
  ethBackend.Commit()
@@ -220,7 +228,7 @@
220
  blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
221
  require.NoError(t, err)
222
  t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order)
223
- assert.Equal(t, uint64(9), blocks[1].BlockNumber)
224
  assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber)
225
  assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator)
226
  assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash)
@@ -232,7 +240,7 @@
232
 
233
  func TestSequenceForceBatchesEvent(t *testing.T) {
234
  // Set up testing environment
235
- etherman, ethBackend, auth, _, _ := newTestingEnv()
236
 
237
  // Read currentBlock
238
  ctx := context.Background()
@@ -283,7 +291,7 @@
283
  blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
284
  require.NoError(t, err)
285
  t.Logf("Blocks: %+v", blocks)
286
- assert.Equal(t, uint64(12), blocks[1].BlockNumber)
287
  assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber)
288
  assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:]))
289
  assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp)
@@ -293,7 +301,7 @@
293
 
294
  func TestSendSequences(t *testing.T) {
295
  // Set up testing environment
296
- etherman, ethBackend, auth, _, br := newTestingEnv()
297
 
298
  // Read currentBlock
299
  ctx := context.Background()
@@ -315,10 +323,11 @@
315
  BatchL2Data: batchL2Data,
316
  LastL2BLockTimestamp: time.Now().Unix(),
317
  }
 
318
  lastL2BlockTStamp := tx1.Time().Unix()
319
- // TODO: fix params
320
- tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From)
321
  require.NoError(t, err)
 
322
  log.Debug("TX: ", tx.Hash())
323
  ethBackend.Commit()
324
 
@@ -341,7 +350,7 @@
341
 
342
  func TestGasPrice(t *testing.T) {
343
  // Set up testing environment
344
- etherman, _, _, _, _ := newTestingEnv()
345
  etherscanM := new(etherscanMock)
346
  ethGasStationM := new(ethGasStationMock)
347
  etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
@@ -360,14 +369,14 @@
360
 
361
  func TestErrorEthGasStationPrice(t *testing.T) {
362
  // Set up testing environment
363
- etherman, _, _, _, _ := newTestingEnv()
364
  ethGasStationM := new(ethGasStationMock)
365
  etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM}
366
  ctx := context.Background()
367
 
368
  ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation"))
369
  gp := etherman.GetL1GasPrice(ctx)
370
- assert.Equal(t, big.NewInt(1392695906), gp)
371
 
372
  etherscanM := new(etherscanMock)
373
  etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
@@ -379,7 +388,7 @@
379
 
380
  func TestErrorEtherScanPrice(t *testing.T) {
381
  // Set up testing environment
382
- etherman, _, _, _, _ := newTestingEnv()
383
  etherscanM := new(etherscanMock)
384
  ethGasStationM := new(ethGasStationMock)
385
  etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
@@ -393,7 +402,7 @@
393
 
394
  func TestGetForks(t *testing.T) {
395
  // Set up testing environment
396
- etherman, _, _, _, _ := newTestingEnv()
397
  ctx := context.Background()
398
  forks, err := etherman.GetForks(ctx, 0, 132)
399
  require.NoError(t, err)
 
38
  }
39
 
40
  // This function prepare the blockchain, the wallet with funds and deploy the smc
41
+ func newTestingEnv(t *testing.T) (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, da *daMock) {
42
  privateKey, err := crypto.GenerateKey()
43
  if err != nil {
44
  log.Fatal(err)
 
47
  if err != nil {
48
  log.Fatal(err)
49
  }
50
+ da = newDaMock(t)
51
+ ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth, da)
52
  if err != nil {
53
  log.Fatal(err)
54
  }
 
56
  if err != nil {
57
  log.Fatal(err)
58
  }
59
+ return ethman, ethBackend, auth, polAddr, br, da
60
  }
61
 
62
  func TestGEREvent(t *testing.T) {
63
  // Set up testing environment
64
+ etherman, ethBackend, auth, _, br, _ := newTestingEnv(t)
65
 
66
  // Read currentBlock
67
  ctx := context.Background()
 
83
  blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
84
  require.NoError(t, err)
85
  t.Logf("Blocks: %+v", blocks)
86
+ assert.Equal(t, uint64(11), blocks[0].L1InfoTree[0].BlockNumber)
87
  assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot)
88
  assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot)
89
  }
90
 
91
  func TestForcedBatchEvent(t *testing.T) {
92
  // Set up testing environment
93
+ etherman, ethBackend, auth, _, _, _ := newTestingEnv(t)
94
 
95
  // Read currentBlock
96
  ctx := context.Background()
 
115
  blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
116
  require.NoError(t, err)
117
  t.Logf("Blocks: %+v", blocks)
118
+ assert.Equal(t, uint64(11), blocks[0].BlockNumber)
119
+ assert.Equal(t, uint64(11), blocks[0].ForcedBatches[0].BlockNumber)
120
  assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot)
121
  assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt)
122
  assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber)
 
126
 
127
  func TestSequencedBatchesEvent(t *testing.T) {
128
  // Set up testing environment
129
+ etherman, ethBackend, auth, _, br, da := newTestingEnv(t)
130
 
131
  // Read currentBlock
132
  ctx := context.Background()
 
157
  blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber)
158
  require.NoError(t, err)
159
  t.Log("Blocks: ", blocks)
160
+ var sequences []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
161
+ txsHash := crypto.Keccak256Hash(common.Hex2Bytes(rawTxs))
162
+ sequences = append(sequences, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
163
+ TransactionsHash: txsHash,
164
+ }, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
165
+ TransactionsHash: txsHash,
166
  })
167
+ batchNums := []uint64{2, 3}
168
+ batchHashes := []common.Hash{txsHash, txsHash}
169
+ batchData := [][]byte{data, data}
170
+ daMessage, _ := hex.DecodeString("0x123456789123456789")
171
+ da.Mock.On("GetBatchL2Data", batchNums, batchHashes, daMessage).Return(batchData, nil)
172
+ _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage)
173
  require.NoError(t, err)
174
 
175
  // Mine the tx in a block
 
195
 
196
  func TestVerifyBatchEvent(t *testing.T) {
197
  // Set up testing environment
198
+ etherman, ethBackend, auth, _, _, da := newTestingEnv(t)
199
 
200
  // Read currentBlock
201
  ctx := context.Background()
 
204
  require.NoError(t, err)
205
 
206
  rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
207
+ tx := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
208
+ TransactionsHash: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)),
209
  }
210
+ daMessage, _ := hex.DecodeString("0x1234")
211
+ _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, []polygonzkevm.PolygonValidiumEtrogValidiumBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage)
212
  require.NoError(t, err)
213
+ da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(common.Hex2Bytes(rawTxs))}, daMessage).Return([][]byte{common.Hex2Bytes(rawTxs)}, nil)
214
 
215
  // Mine the tx in a block
216
  ethBackend.Commit()
 
228
  blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
229
  require.NoError(t, err)
230
  t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order)
231
+ assert.Equal(t, uint64(12), blocks[1].BlockNumber)
232
  assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber)
233
  assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator)
234
  assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash)
 
240
 
241
  func TestSequenceForceBatchesEvent(t *testing.T) {
242
  // Set up testing environment
243
+ etherman, ethBackend, auth, _, _, _ := newTestingEnv(t)
244
 
245
  // Read currentBlock
246
  ctx := context.Background()
 
291
  blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
292
  require.NoError(t, err)
293
  t.Logf("Blocks: %+v", blocks)
294
+ assert.Equal(t, uint64(15), blocks[1].BlockNumber)
295
  assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber)
296
  assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:]))
297
  assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp)
 
301
 
302
  func TestSendSequences(t *testing.T) {
303
  // Set up testing environment
304
+ etherman, ethBackend, auth, _, br, da := newTestingEnv(t)
305
 
306
  // Read currentBlock
307
  ctx := context.Background()
 
323
  BatchL2Data: batchL2Data,
324
  LastL2BLockTimestamp: time.Now().Unix(),
325
  }
326
+ daMessage, _ := hex.DecodeString("0x1234")
327
  lastL2BlockTStamp := tx1.Time().Unix()
328
+ tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From, daMessage)
 
329
  require.NoError(t, err)
330
+ da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(batchL2Data)}, daMessage).Return([][]byte{batchL2Data}, nil)
331
  log.Debug("TX: ", tx.Hash())
332
  ethBackend.Commit()
333
 
 
350
 
351
  func TestGasPrice(t *testing.T) {
352
  // Set up testing environment
353
+ etherman, _, _, _, _, _ := newTestingEnv(t)
354
  etherscanM := new(etherscanMock)
355
  ethGasStationM := new(ethGasStationMock)
356
  etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
 
369
 
370
  func TestErrorEthGasStationPrice(t *testing.T) {
371
  // Set up testing environment
372
+ etherman, _, _, _, _, _ := newTestingEnv(t)
373
  ethGasStationM := new(ethGasStationMock)
374
  etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM}
375
  ctx := context.Background()
376
 
377
  ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation"))
378
  gp := etherman.GetL1GasPrice(ctx)
379
+ assert.Equal(t, big.NewInt(1263075579), gp)
380
 
381
  etherscanM := new(etherscanMock)
382
  etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
 
388
 
389
  func TestErrorEtherScanPrice(t *testing.T) {
390
  // Set up testing environment
391
+ etherman, _, _, _, _, _ := newTestingEnv(t)
392
  etherscanM := new(etherscanMock)
393
  ethGasStationM := new(ethGasStationMock)
394
  etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
 
402
 
403
  func TestGetForks(t *testing.T) {
404
  // Set up testing environment
405
+ etherman, _, _, _, _, _ := newTestingEnv(t)
406
  ctx := context.Background()
407
  forks, err := etherman.GetForks(ctx, 0, 132)
408
  require.NoError(t, err)
{/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/interfaces.go RENAMED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ package etherman
2
+
3
+ import "github.com/ethereum/go-ethereum/common"
4
+
5
+ type dataAvailabilityProvider interface {
6
+ GetBatchL2Data(batchNum []uint64, hash []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error)
7
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go RENAMED
@@ -23,7 +24,7 @@
23
 
24
  // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
25
  // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
26
- func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (*Client, *simulated.Backend, common.Address, *polygonzkevmbridge.Polygonzkevmbridge, error) {
27
  if auth == nil {
28
  // read only client
29
  return &Client{}, nil, common.Address{}, nil, nil
@@ -37,8 +38,26 @@
37
  },
38
  }
39
  blockGasLimit := uint64(999999999999999999) //nolint:gomnd
 
40
  client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  // Deploy contracts
43
  const polDecimalPlaces = 18
44
  totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd
@@ -102,7 +121,7 @@
102
  log.Error("error: ", err)
103
  return nil, nil, common.Address{}, nil, err
104
  }
105
- br, err := polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client())
106
  if err != nil {
107
  log.Error("error: ", err)
108
  return nil, nil, common.Address{}, nil, err
@@ -182,6 +201,11 @@
182
  return nil, nil, common.Address{}, nil, err
183
  }
184
 
 
 
 
 
 
185
  _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{})
186
  if err != nil {
187
  log.Error("error: ", err)
@@ -199,6 +223,7 @@
199
  SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr},
200
  auth: map[common.Address]bind.TransactOpts{},
201
  cfg: cfg,
 
202
  }
203
  err = c.AddOrReplaceAuth(*auth)
204
  if err != nil {
 
24
 
25
  // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
26
  // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
27
+ func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts, daBackend dataAvailabilityProvider) (etherman *Client, ethBackend *simulated.Backend, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, err error) {
28
  if auth == nil {
29
  // read only client
30
  return &Client{}, nil, common.Address{}, nil, nil
 
38
  },
39
  }
40
  blockGasLimit := uint64(999999999999999999) //nolint:gomnd
41
+ // client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
42
  client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
43
 
44
+ // DAC Setup
45
+ daAddr, _, da, err := polygondatacommittee.DeployPolygondatacommittee(auth, client.Client())
46
+ if err != nil {
47
+ return nil, nil, common.Address{}, nil, err
48
+ }
49
+ client.Commit()
50
+ _, err = da.Initialize(auth)
51
+ if err != nil {
52
+ return nil, nil, common.Address{}, nil, err
53
+ }
54
+ client.Commit()
55
+ _, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{})
56
+ if err != nil {
57
+ return nil, nil, common.Address{}, nil, err
58
+ }
59
+ client.Commit()
60
+
61
  // Deploy contracts
62
  const polDecimalPlaces = 18
63
  totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd
 
121
  log.Error("error: ", err)
122
  return nil, nil, common.Address{}, nil, err
123
  }
124
+ br, err = polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client())
125
  if err != nil {
126
  log.Error("error: ", err)
127
  return nil, nil, common.Address{}, nil, err
 
201
  return nil, nil, common.Address{}, nil, err
202
  }
203
 
204
+ _, err = trueZkevm.SetDataAvailabilityProtocol(auth, daAddr)
205
+ if err != nil {
206
+ log.Error("error: ", err)
207
+ return nil, nil, common.Address{}, nil, err
208
+ }
209
  _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{})
210
  if err != nil {
211
  log.Error("error: ", err)
 
223
  SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr},
224
  auth: map[common.Address]bind.TransactOpts{},
225
  cfg: cfg,
226
+ da: daBackend,
227
  }
228
  err = c.AddOrReplaceAuth(*auth)
229
  if err != nil {
{/home/stefan/go/src/Polygon/zkevm-node → .}/event/event.go RENAMED
@@ -42,6 +42,9 @@
42
  EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT"
43
  // EventID_SequenceSenderHalt is triggered when the SequenceSender halts
44
  EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT"
 
 
 
45
  // EventID_NodeOOC is triggered when an OOC at node level is detected
46
  EventID_NodeOOC EventID = "NODE OOC"
47
  // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters
 
42
  EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT"
43
  // EventID_SequenceSenderHalt is triggered when the SequenceSender halts
44
  EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT"
45
+ // EventID_UnsupportedPrecompile is triggered when the executor returns an unsupported precompile error
46
+ EventID_UnsupportedPrecompile EventID = "UNSUPPORTED PRECOMPILE"
47
+
48
  // EventID_NodeOOC is triggered when an OOC at node level is detected
49
  EventID_NodeOOC EventID = "NODE OOC"
50
  // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters
{/home/stefan/go/src/Polygon/zkevm-node → .}/.golangci.yml RENAMED
@@ -30,3 +30,6 @@
30
  include:
31
  - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
32
  - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
 
 
 
 
30
  include:
31
  - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
32
  - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
33
+ exclude-rules:
34
+ - path: cmd/policy.go
35
+ text: "unused"
{/home/stefan/go/src/Polygon/zkevm-node → .}/go.mod RENAMED
@@ -22,9 +22,9 @@
22
  github.com/prometheus/common v0.45.0
23
  github.com/rubenv/sql-migrate v1.6.1
24
  github.com/spf13/afero v1.11.0
25
- github.com/spf13/viper v1.17.0
26
  github.com/stretchr/testify v1.8.4
27
- github.com/umbracle/ethgo v0.1.3
28
  github.com/urfave/cli/v2 v2.26.0
29
  go.uber.org/zap v1.26.0
30
  golang.org/x/crypto v0.18.0
@@ -45,7 +45,7 @@
45
  github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
46
  github.com/bahlo/generic-list-go v0.2.0 // indirect
47
  github.com/beorn7/perks v1.0.1 // indirect
48
- github.com/bits-and-blooms/bitset v1.10.0 // indirect
49
  github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
50
  github.com/buger/jsonparser v1.1.1 // indirect
51
  github.com/cespare/xxhash/v2 v2.2.0 // indirect
@@ -63,12 +63,12 @@
63
  github.com/cyphar/filepath-securejoin v0.2.4 // indirect
64
  github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
65
  github.com/deckarep/golang-set/v2 v2.1.0 // indirect
66
- github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
67
  github.com/dlclark/regexp2 v1.7.0 // indirect
68
  github.com/emirpasic/gods v1.18.1 // indirect
69
  github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
70
  github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
71
- github.com/fsnotify/fsnotify v1.6.0 // indirect
72
  github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
73
  github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
74
  github.com/getsentry/sentry-go v0.18.0 // indirect
@@ -101,6 +101,7 @@
101
  github.com/jackc/puddle v1.3.0 // indirect
102
  github.com/jackpal/go-nat-pmp v1.0.2 // indirect
103
  github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
 
104
  github.com/karrick/godirwalk v1.17.0 // indirect
105
  github.com/kevinburke/ssh_config v1.2.0 // indirect
106
  github.com/klauspost/compress v1.17.0 // indirect
@@ -116,6 +117,7 @@
116
  github.com/mattn/go-isatty v0.0.20 // indirect
117
  github.com/mattn/go-runewidth v0.0.13 // indirect
118
  github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
 
119
  github.com/mitchellh/pointerstructure v1.2.0 // indirect
120
  github.com/mmcloughlin/addchain v0.4.0 // indirect
121
  github.com/olekukonko/tablewriter v0.0.5 // indirect
@@ -128,14 +130,14 @@
128
  github.com/rogpeppe/go-internal v1.11.0 // indirect
129
  github.com/rs/cors v1.7.0 // indirect
130
  github.com/russross/blackfriday/v2 v2.1.0 // indirect
131
- github.com/sagikazarmark/locafero v0.3.0 // indirect
132
  github.com/sagikazarmark/slog-shim v0.1.0 // indirect
133
  github.com/sergi/go-diff v1.2.0 // indirect
134
  github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
135
  github.com/sirupsen/logrus v1.9.0 // indirect
136
  github.com/skeema/knownhosts v1.2.1 // indirect
137
  github.com/sourcegraph/conc v0.3.0 // indirect
138
- github.com/spf13/cast v1.5.1 // indirect
139
  github.com/spf13/pflag v1.0.5 // indirect
140
  github.com/status-im/keycard-go v0.2.0 // indirect
141
  github.com/stretchr/objx v0.5.0 // indirect
 
22
  github.com/prometheus/common v0.45.0
23
  github.com/rubenv/sql-migrate v1.6.1
24
  github.com/spf13/afero v1.11.0
25
+ github.com/spf13/viper v1.18.2
26
  github.com/stretchr/testify v1.8.4
27
+ github.com/umbracle/ethgo v0.1.4-0.20230712173909-df37dddf16f0
28
  github.com/urfave/cli/v2 v2.26.0
29
  go.uber.org/zap v1.26.0
30
  golang.org/x/crypto v0.18.0
 
45
  github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
46
  github.com/bahlo/generic-list-go v0.2.0 // indirect
47
  github.com/beorn7/perks v1.0.1 // indirect
48
+ github.com/bits-and-blooms/bitset v1.12.0 // indirect
49
  github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
50
  github.com/buger/jsonparser v1.1.1 // indirect
51
  github.com/cespare/xxhash/v2 v2.2.0 // indirect
 
63
  github.com/cyphar/filepath-securejoin v0.2.4 // indirect
64
  github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
65
  github.com/deckarep/golang-set/v2 v2.1.0 // indirect
66
+ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
67
  github.com/dlclark/regexp2 v1.7.0 // indirect
68
  github.com/emirpasic/gods v1.18.1 // indirect
69
  github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
70
  github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
71
+ github.com/fsnotify/fsnotify v1.7.0 // indirect
72
  github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
73
  github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
74
  github.com/getsentry/sentry-go v0.18.0 // indirect
 
101
  github.com/jackc/puddle v1.3.0 // indirect
102
  github.com/jackpal/go-nat-pmp v1.0.2 // indirect
103
  github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
104
+ github.com/jmoiron/sqlx v1.2.0 // indirect
105
  github.com/karrick/godirwalk v1.17.0 // indirect
106
  github.com/kevinburke/ssh_config v1.2.0 // indirect
107
  github.com/klauspost/compress v1.17.0 // indirect
 
117
  github.com/mattn/go-isatty v0.0.20 // indirect
118
  github.com/mattn/go-runewidth v0.0.13 // indirect
119
  github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
120
+ github.com/miguelmota/go-solidity-sha3 v0.1.1 // indirect
121
  github.com/mitchellh/pointerstructure v1.2.0 // indirect
122
  github.com/mmcloughlin/addchain v0.4.0 // indirect
123
  github.com/olekukonko/tablewriter v0.0.5 // indirect
 
130
  github.com/rogpeppe/go-internal v1.11.0 // indirect
131
  github.com/rs/cors v1.7.0 // indirect
132
  github.com/russross/blackfriday/v2 v2.1.0 // indirect
133
+ github.com/sagikazarmark/locafero v0.4.0 // indirect
134
  github.com/sagikazarmark/slog-shim v0.1.0 // indirect
135
  github.com/sergi/go-diff v1.2.0 // indirect
136
  github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
137
  github.com/sirupsen/logrus v1.9.0 // indirect
138
  github.com/skeema/knownhosts v1.2.1 // indirect
139
  github.com/sourcegraph/conc v0.3.0 // indirect
140
+ github.com/spf13/cast v1.6.0 // indirect
141
  github.com/spf13/pflag v1.0.5 // indirect
142
  github.com/status-im/keycard-go v0.2.0 // indirect
143
  github.com/stretchr/objx v0.5.0 // indirect
{/home/stefan/go/src/Polygon/zkevm-node → .}/.goreleaser-cdk.yaml RENAMED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # .goreleaser-cdk.yaml
2
+ project_name: cdk-validium-node
3
+
4
+ release:
5
+ disable: false
6
+ draft: true
7
+ prerelease: auto
8
+
9
+ before:
10
+ hooks:
11
+ - go mod download
12
+ - go install github.com/gobuffalo/packr/v2/packr2@v2.8.3
13
+ - packr2
14
+
15
+ builds:
16
+ - main: ./cmd/
17
+ binary: zkevm-node
18
+ goos:
19
+ - linux
20
+ - darwin
21
+ goarch:
22
+ - amd64
23
+ - arm64
24
+ env:
25
+ - CGO_ENABLED=0
26
+ ldflags:
27
+ - -s -w
28
+ - -X github.com/0xPolygonHermez/zkevm-node.Version={{ .Version }}
29
+ - -X github.com/0xPolygonHermez/zkevm-node.GitRev={{ .Commit }}
30
+ - -X github.com/0xPolygonHermez/zkevm-node.BuildDate={{ .Date }}
31
+ - -X github.com/0xPolygonHermez/zkevm-node.GitBranch={{ .Branch }}
32
+
33
+ archives:
34
+ - files:
35
+ - LICENSE
36
+ - README.md
37
+
38
+ dockers:
39
+ - image_templates:
40
+ - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64
41
+ dockerfile: Dockerfile.release
42
+ use: buildx
43
+ goos: linux
44
+ goarch: amd64
45
+ build_flag_templates:
46
+ - --platform=linux/amd64
47
+ - --label=org.opencontainers.image.title={{ .ProjectName }}
48
+ - --label=org.opencontainers.image.description={{ .ProjectName }}
49
+ - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }}
50
+ - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }}
51
+ - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }}
52
+ - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
53
+ - --label=org.opencontainers.image.revision={{ .FullCommit }}
54
+ skip_push: false
55
+
56
+ - image_templates:
57
+ - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64
58
+ dockerfile: Dockerfile.release
59
+ use: buildx
60
+ goos: linux
61
+ goarch: arm64
62
+ build_flag_templates:
63
+ - --platform=linux/arm64
64
+ - --label=org.opencontainers.image.title={{ .ProjectName }}
65
+ - --label=org.opencontainers.image.description={{ .ProjectName }}
66
+ - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }}
67
+ - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }}
68
+ - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }}
69
+ - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
70
+ - --label=org.opencontainers.image.revision={{ .FullCommit }}
71
+ skip_push: false
72
+
73
+ docker_manifests:
74
+ - name_template: 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}
75
+ image_templates:
76
+ - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64
77
+ - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64
78
+ skip_push: false
79
+
80
+ - name_template: 0xpolygon/{{ .ProjectName }}:latest
81
+ image_templates:
82
+ - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64
83
+ - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64
84
+ skip_push: false
{/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/client/zkevm.go RENAMED
@@ -58,6 +58,40 @@
58
  return result, nil
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root
62
  func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) {
63
  response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String())
 
58
  return result, nil
59
  }
60
 
61
+ // BatchesByNumbers returns batches from the current canonical chain by batch numbers. If the list is empty, the last
62
+ // known batch is returned as a list.
63
+ func (c *Client) BatchesByNumbers(_ context.Context, numbers []*big.Int) ([]*types.BatchData, error) {
64
+ var list []types.BatchNumber
65
+ for _, n := range numbers {
66
+ list = append(list, types.BatchNumber(n.Int64()))
67
+ }
68
+ if len(list) == 0 {
69
+ list = append(list, types.LatestBatchNumber)
70
+ }
71
+
72
+ var batchNumbers []string
73
+ for _, n := range list {
74
+ batchNumbers = append(batchNumbers, n.StringOrHex())
75
+ }
76
+
77
+ response, err := JSONRPCCall(c.url, "zkevm_getBatchDataByNumbers", batchNumbers, true)
78
+ if err != nil {
79
+ return nil, err
80
+ }
81
+
82
+ if response.Error != nil {
83
+ return nil, response.Error.RPCError()
84
+ }
85
+
86
+ var result *types.BatchDataResult
87
+ err = json.Unmarshal(response.Result, &result)
88
+ if err != nil {
89
+ return nil, err
90
+ }
91
+
92
+ return result.Data, nil
93
+ }
94
+
95
  // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root
96
  func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) {
97
  response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String())
{/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go RENAMED
@@ -106,7 +106,7 @@
106
  result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx)
107
  if err != nil {
108
  errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error())
109
- logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !errors.Is(err, runtime.ErrOutOfGas)
110
  return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError)
111
  }
112
 
@@ -941,6 +941,9 @@
941
  if e.cfg.SequencerNodeURI != "" {
942
  return e.relayTxToSequencerNode(input)
943
  } else {
 
 
 
944
  ip := ""
945
  ips := httpRequest.Header.Get("X-Forwarded-For")
946
 
 
106
  result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx)
107
  if err != nil {
108
  errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error())
109
+ logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !(errors.Is(err, runtime.ErrOutOfGas))
110
  return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError)
111
  }
112
 
 
941
  if e.cfg.SequencerNodeURI != "" {
942
  return e.relayTxToSequencerNode(input)
943
  } else {
944
+ if err := checkPolicy(context.Background(), e.pool, input); err != nil {
945
+ return RPCErrorResponse(types.AccessDeniedCode, err.Error(), nil, false)
946
+ }
947
  ip := ""
948
  ips := httpRequest.Header.Get("X-Forwarded-For")
949
 
{/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go RENAMED
@@ -6,6 +6,7 @@
6
  "errors"
7
  "fmt"
8
  "math/big"
 
9
  "sync"
10
  "testing"
11
  "time"
@@ -3311,7 +3312,7 @@
3311
  receipt.Bloom = ethTypes.CreateBloom(ethTypes.Receipts{receipt})
3312
 
3313
  rpcReceipt := types.Receipt{
3314
- Root: stateRoot,
3315
  CumulativeGasUsed: types.ArgUint64(receipt.CumulativeGasUsed),
3316
  LogsBloom: receipt.Bloom,
3317
  Logs: receipt.Logs,
@@ -5416,3 +5417,237 @@
5416
  assert.ElementsMatch(t, []int{13, 14, 15}, results[4])
5417
  assert.ElementsMatch(t, []int{16}, results[5])
5418
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  "errors"
7
  "fmt"
8
  "math/big"
9
+ "strings"
10
  "sync"
11
  "testing"
12
  "time"
 
3312
  receipt.Bloom = ethTypes.CreateBloom(ethTypes.Receipts{receipt})
3313
 
3314
  rpcReceipt := types.Receipt{
3315
+ Root: &stateRoot,
3316
  CumulativeGasUsed: types.ArgUint64(receipt.CumulativeGasUsed),
3317
  LogsBloom: receipt.Bloom,
3318
  Logs: receipt.Logs,
 
5417
  assert.ElementsMatch(t, []int{13, 14, 15}, results[4])
5418
  assert.ElementsMatch(t, []int{16}, results[5])
5419
  }
5420
+
5421
+ func TestSendRawTransactionJSONRPCCallWithPolicyApplied(t *testing.T) {
5422
+ // Set up the sender
5423
+ allowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x"))
5424
+ require.NoError(t, err)
5425
+ allowed, err := bind.NewKeyedTransactorWithChainID(allowedPrivateKey, big.NewInt(1))
5426
+ require.NoError(t, err)
5427
+
5428
+ disallowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0xdeadbeef8721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x"))
5429
+ require.NoError(t, err)
5430
+ disallowed, err := bind.NewKeyedTransactorWithChainID(disallowedPrivateKey, big.NewInt(1))
5431
+ require.NoError(t, err)
5432
+ require.NotNil(t, disallowed)
5433
+
5434
+ allowedContract := common.HexToAddress("0x1")
5435
+ disallowedContract := common.HexToAddress("0x2")
5436
+
5437
+ senderDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed send_tx by policy")
5438
+ contractDenied := types.NewRPCError(types.AccessDeniedCode, "contract disallowed send_tx by policy")
5439
+ deployDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed deploy by policy")
5440
+
5441
+ cfg := getSequencerDefaultConfig()
5442
+ s, m, _ := newMockedServerWithCustomConfig(t, cfg)
5443
+ defer s.Stop()
5444
+
5445
+ type testCase struct {
5446
+ Name string
5447
+ Input string
5448
+ ExpectedResult *common.Hash
5449
+ ExpectedError types.Error
5450
+ Prepare func(t *testing.T, tc *testCase)
5451
+ SetupMocks func(t *testing.T, m *mocksWrapper, tc testCase)
5452
+ }
5453
+
5454
+ testCases := []testCase{
5455
+ {
5456
+ Name: "Sender & contract on allow list, accepted",
5457
+ Prepare: func(t *testing.T, tc *testCase) {
5458
+ tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
5459
+
5460
+ signedTx, err := allowed.Signer(allowed.From, tx)
5461
+ require.NoError(t, err)
5462
+
5463
+ txBinary, err := signedTx.MarshalBinary()
5464
+ require.NoError(t, err)
5465
+
5466
+ rawTx := hex.EncodeToHex(txBinary)
5467
+ require.NoError(t, err)
5468
+
5469
+ tc.Input = rawTx
5470
+ expectedHash := signedTx.Hash()
5471
+ tc.ExpectedResult = &expectedHash
5472
+ tc.ExpectedError = nil
5473
+ },
5474
+ SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
5475
+ m.Pool.
5476
+ On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), "").
5477
+ Return(nil).
5478
+ Once()
5479
+ m.Pool.
5480
+ On("CheckPolicy", context.Background(), pool.SendTx, allowedContract).
5481
+ Return(true, nil).
5482
+ Once()
5483
+ m.Pool.
5484
+ On("CheckPolicy", context.Background(), pool.SendTx, allowed.From).
5485
+ Return(true, nil).
5486
+ Once()
5487
+ },
5488
+ },
5489
+ {
5490
+ Name: "Contract not on allow list, rejected",
5491
+ Prepare: func(t *testing.T, tc *testCase) {
5492
+ tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
5493
+
5494
+ signedTx, err := allowed.Signer(allowed.From, tx)
5495
+ require.NoError(t, err)
5496
+
5497
+ txBinary, err := signedTx.MarshalBinary()
5498
+ require.NoError(t, err)
5499
+
5500
+ rawTx := hex.EncodeToHex(txBinary)
5501
+ require.NoError(t, err)
5502
+
5503
+ tc.Input = rawTx
5504
+ tc.ExpectedResult = nil
5505
+ tc.ExpectedError = contractDenied
5506
+ },
5507
+ SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
5508
+ m.Pool.
5509
+ On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract).
5510
+ Return(false, contractDenied).
5511
+ Once()
5512
+ },
5513
+ },
5514
+ {
5515
+ Name: "Sender not on allow list, rejected",
5516
+ Prepare: func(t *testing.T, tc *testCase) {
5517
+ tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
5518
+
5519
+ signedTx, err := disallowed.Signer(disallowed.From, tx)
5520
+ require.NoError(t, err)
5521
+
5522
+ txBinary, err := signedTx.MarshalBinary()
5523
+ require.NoError(t, err)
5524
+
5525
+ rawTx := hex.EncodeToHex(txBinary)
5526
+ require.NoError(t, err)
5527
+
5528
+ tc.Input = rawTx
5529
+ tc.ExpectedResult = nil
5530
+ tc.ExpectedError = senderDenied
5531
+ },
5532
+ SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
5533
+ m.Pool.
5534
+ On("CheckPolicy", context.Background(), pool.SendTx, allowedContract).
5535
+ Return(true, nil).
5536
+ Once()
5537
+ m.Pool.
5538
+ On("CheckPolicy", context.Background(), pool.SendTx, disallowed.From).
5539
+ Return(false, senderDenied).
5540
+ Once()
5541
+ },
5542
+ },
5543
+ {
5544
+ Name: "Unsigned tx with allowed contract, accepted", // for backward compatibility
5545
+ Prepare: func(t *testing.T, tc *testCase) {
5546
+ tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
5547
+
5548
+ txBinary, err := tx.MarshalBinary()
5549
+ require.NoError(t, err)
5550
+
5551
+ rawTx := hex.EncodeToHex(txBinary)
5552
+ require.NoError(t, err)
5553
+
5554
+ tc.Input = rawTx
5555
+ expectedHash := tx.Hash()
5556
+ tc.ExpectedResult = &expectedHash
5557
+ tc.ExpectedError = nil
5558
+ },
5559
+ SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
5560
+ m.Pool.
5561
+ On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), "").
5562
+ Return(nil).
5563
+ Once()
5564
+ // policy does not reject this case for backward compat
5565
+ },
5566
+ },
5567
+ {
5568
+ Name: "Unsigned tx with disallowed contract, rejected",
5569
+ Prepare: func(t *testing.T, tc *testCase) {
5570
+ tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
5571
+
5572
+ signedTx, err := disallowed.Signer(disallowed.From, tx)
5573
+ require.NoError(t, err)
5574
+
5575
+ txBinary, err := signedTx.MarshalBinary()
5576
+ require.NoError(t, err)
5577
+
5578
+ rawTx := hex.EncodeToHex(txBinary)
5579
+ require.NoError(t, err)
5580
+
5581
+ tc.Input = rawTx
5582
+ tc.ExpectedResult = nil
5583
+ tc.ExpectedError = contractDenied
5584
+ },
5585
+ SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
5586
+ m.Pool.
5587
+ On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract).
5588
+ Return(false, contractDenied).
5589
+ Once()
5590
+ },
5591
+ },
5592
+ {
5593
+ Name: "Send invalid tx input", // for backward compatibility
5594
+ Prepare: func(t *testing.T, tc *testCase) {
5595
+ tc.Input = "0x1234"
5596
+ tc.ExpectedResult = nil
5597
+ tc.ExpectedError = types.NewRPCError(types.InvalidParamsErrorCode, "invalid tx input")
5598
+ },
5599
+ SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {},
5600
+ },
5601
+ {
5602
+ Name: "Sender not on deploy allow list, rejected",
5603
+ Prepare: func(t *testing.T, tc *testCase) {
5604
+ deployAddr := common.HexToAddress("0x0")
5605
+ tx := ethTypes.NewTransaction(1, deployAddr, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
5606
+
5607
+ signedTx, err := disallowed.Signer(disallowed.From, tx)
5608
+ require.NoError(t, err)
5609
+
5610
+ txBinary, err := signedTx.MarshalBinary()
5611
+ require.NoError(t, err)
5612
+
5613
+ rawTx := hex.EncodeToHex(txBinary)
5614
+ require.NoError(t, err)
5615
+
5616
+ tc.Input = rawTx
5617
+ tc.ExpectedResult = nil
5618
+ tc.ExpectedError = deployDenied
5619
+ },
5620
+ SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
5621
+ m.Pool.
5622
+ On("CheckPolicy", context.Background(), pool.Deploy, disallowed.From).
5623
+ Return(false, nil).
5624
+ Once()
5625
+ },
5626
+ },
5627
+ }
5628
+
5629
+ for _, testCase := range testCases {
5630
+ t.Run(testCase.Name, func(t *testing.T) {
5631
+ tc := testCase
5632
+ tc.Prepare(t, &tc)
5633
+ tc.SetupMocks(t, m, tc)
5634
+
5635
+ res, err := s.JSONRPCCall("eth_sendRawTransaction", tc.Input)
5636
+ require.NoError(t, err)
5637
+
5638
+ assert.Equal(t, float64(1), res.ID)
5639
+ assert.Equal(t, "2.0", res.JSONRPC)
5640
+
5641
+ if res.Result != nil || tc.ExpectedResult != nil {
5642
+ var result common.Hash
5643
+ err = json.Unmarshal(res.Result, &result)
5644
+ require.NoError(t, err)
5645
+ assert.Equal(t, *tc.ExpectedResult, result)
5646
+ }
5647
+ if res.Error != nil || tc.ExpectedError != nil {
5648
+ assert.Equal(t, tc.ExpectedError.ErrorCode(), res.Error.Code)
5649
+ assert.Equal(t, tc.ExpectedError.Error(), res.Error.Message)
5650
+ }
5651
+ })
5652
+ }
5653
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm.go RENAMED
@@ -204,6 +204,42 @@
204
  })
205
  }
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  // GetFullBlockByNumber returns information about a block by block number
208
  func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) {
209
  return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
 
204
  })
205
  }
206
 
207
+ // GetBatchDataByNumbers returns the batch data for batches by numbers
208
+ func (z *ZKEVMEndpoints) GetBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) {
209
+ return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
210
+ var batchNumbers []uint64
211
+ for _, bn := range filter.Numbers {
212
+ n, rpcErr := bn.GetNumericBatchNumber(ctx, z.state, z.etherman, dbTx)
213
+ if rpcErr != nil {
214
+ return nil, rpcErr
215
+ }
216
+ batchNumbers = append(batchNumbers, n)
217
+ }
218
+
219
+ batchesData, err := z.state.GetBatchL2DataByNumbers(ctx, batchNumbers, dbTx)
220
+ if errors.Is(err, state.ErrNotFound) {
221
+ return nil, nil
222
+ } else if err != nil {
223
+ return RPCErrorResponse(types.DefaultErrorCode,
224
+ fmt.Sprintf("couldn't load batch data from state by numbers %v", filter.Numbers), err, true)
225
+ }
226
+
227
+ var ret []*types.BatchData
228
+ for _, n := range batchNumbers {
229
+ data := &types.BatchData{Number: types.ArgUint64(n)}
230
+ if b, ok := batchesData[n]; ok {
231
+ data.BatchL2Data = b
232
+ data.Empty = false
233
+ } else {
234
+ data.Empty = true
235
+ }
236
+ ret = append(ret, data)
237
+ }
238
+
239
+ return types.BatchDataResult{Data: ret}, nil
240
+ })
241
+ }
242
+
243
  // GetFullBlockByNumber returns information about a block by block number
244
  func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) {
245
  return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
{/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm_test.go RENAMED
@@ -2260,7 +2260,7 @@
2260
  receipt.Bloom = ethTypes.CreateBloom(ethTypes.Receipts{receipt})
2261
 
2262
  rpcReceipt := types.Receipt{
2263
- Root: stateRoot,
2264
  CumulativeGasUsed: types.ArgUint64(receipt.CumulativeGasUsed),
2265
  LogsBloom: receipt.Bloom,
2266
  Logs: receipt.Logs,
 
2260
  receipt.Bloom = ethTypes.CreateBloom(ethTypes.Receipts{receipt})
2261
 
2262
  rpcReceipt := types.Receipt{
2263
+ Root: &stateRoot,
2264
  CumulativeGasUsed: types.ArgUint64(receipt.CumulativeGasUsed),
2265
  LogsBloom: receipt.Bloom,
2266
  Logs: receipt.Logs,
{/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/policy.go RENAMED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package jsonrpc
2
+
3
+ import (
4
+ "context"
5
+
6
+ "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
7
+ "github.com/0xPolygonHermez/zkevm-node/pool"
8
+ "github.com/0xPolygonHermez/zkevm-node/state"
9
+ "github.com/ethereum/go-ethereum/common"
10
+ ethTypes "github.com/ethereum/go-ethereum/core/types"
11
+ )
12
+
13
+ func checkPolicy(ctx context.Context, p types.PoolInterface, input string) error {
14
+ tx, err := hexToTx(input)
15
+ if err != nil {
16
+ // ignore it, let the later processing reject
17
+ return nil
18
+ }
19
+
20
+ // if the tx is signed, check the from address. If there is no from address, the tx is not rejected as it
21
+ // will get rejected later. This maintains backward compatibility with RPC expectations. TODO: verify this is ok behavior
22
+ var from common.Address
23
+ if from, err = state.GetSender(*tx); err != nil {
24
+ // if not signed, then skip check, it fails later on its own
25
+ return nil
26
+ }
27
+
28
+ switch resolvePolicy(tx) {
29
+ case pool.SendTx:
30
+ var allow bool
31
+ if allow, err = p.CheckPolicy(ctx, pool.SendTx, *tx.To()); err != nil {
32
+ return err
33
+ }
34
+ if !allow {
35
+ return pool.ErrContractDisallowedSendTx
36
+ }
37
+ if allow, err = p.CheckPolicy(ctx, pool.SendTx, from); err != nil {
38
+ return err
39
+ }
40
+ if !allow {
41
+ return pool.ErrSenderDisallowedSendTx
42
+ }
43
+ case pool.Deploy:
44
+ var allow bool
45
+ // check that sender may deploy contracts
46
+ if allow, err = p.CheckPolicy(ctx, pool.Deploy, from); err != nil {
47
+ return err
48
+ }
49
+ if !allow {
50
+ return pool.ErrSenderDisallowedDeploy
51
+ }
52
+ }
53
+ return nil
54
+ }
55
+
56
+ func resolvePolicy(tx *ethTypes.Transaction) pool.PolicyName {
57
+ if tx.To() == nil || tx.To().Hex() == common.HexToAddress("0x0").Hex() {
58
+ return pool.Deploy
59
+ }
60
+ return pool.SendTx
61
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/errors.go RENAMED
@@ -15,6 +15,8 @@
15
  InvalidParamsErrorCode = -32602
16
  // ParserErrorCode error code for parsing errors
17
  ParserErrorCode = -32700
 
 
18
  )
19
 
20
  var (
 
15
  InvalidParamsErrorCode = -32602
16
  // ParserErrorCode error code for parsing errors
17
  ParserErrorCode = -32700
18
+ // AccessDeniedCode error code when requests are denied
19
+ AccessDeniedCode = -32800
20
  )
21
 
22
  var (
{/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/interfaces.go RENAMED
@@ -23,6 +23,7 @@
23
  CountPendingTransactions(ctx context.Context) (uint64, error)
24
  GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
25
  GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
 
26
  CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error)
27
  CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error)
28
  EffectiveGasPriceEnabled() bool
@@ -64,6 +65,7 @@
64
  GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
65
  GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
66
  GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
 
67
  GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error)
68
  GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error)
69
  GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error)
 
23
  CountPendingTransactions(ctx context.Context) (uint64, error)
24
  GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
25
  GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
26
+ CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error)
27
  CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error)
28
  CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error)
29
  EffectiveGasPriceEnabled() bool
 
65
  GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
66
  GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
67
  GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
68
+ GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
69
  GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error)
70
  GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error)
71
  GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error)
{/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/types.go RENAMED
@@ -446,6 +446,23 @@
446
  return res, nil
447
  }
448
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  // TransactionOrHash for union type of transaction and types.Hash
450
  type TransactionOrHash struct {
451
  Hash *common.Hash
@@ -601,7 +618,7 @@
601
 
602
  // Receipt structure
603
  type Receipt struct {
604
- Root common.Hash `json:"root"`
605
  CumulativeGasUsed ArgUint64 `json:"cumulativeGasUsed"`
606
  LogsBloom types.Bloom `json:"logsBloom"`
607
  Logs []*types.Log `json:"logs"`
@@ -643,7 +660,6 @@
643
  return Receipt{}, err
644
  }
645
  receipt := Receipt{
646
- Root: common.BytesToHash(r.PostState),
647
  CumulativeGasUsed: ArgUint64(r.CumulativeGasUsed),
648
  LogsBloom: r.Bloom,
649
  Logs: logs,
@@ -659,6 +675,11 @@
659
  Type: ArgUint64(r.Type),
660
  TxL2Hash: l2Hash,
661
  }
 
 
 
 
 
662
  if r.EffectiveGasPrice != nil {
663
  egp := ArgBig(*r.EffectiveGasPrice)
664
  receipt.EffectiveGasPrice = &egp
 
446
  return res, nil
447
  }
448
 
449
+ // BatchFilter is a list of batch numbers to retrieve
450
+ type BatchFilter struct {
451
+ Numbers []BatchNumber `json:"numbers"`
452
+ }
453
+
454
+ // BatchData is an abbreviated structure that only contains the number and L2 batch data
455
+ type BatchData struct {
456
+ Number ArgUint64 `json:"number"`
457
+ BatchL2Data ArgBytes `json:"batchL2Data,omitempty"`
458
+ Empty bool `json:"empty"`
459
+ }
460
+
461
+ // BatchDataResult is a list of BatchData for a BatchFilter
462
+ type BatchDataResult struct {
463
+ Data []*BatchData `json:"data"`
464
+ }
465
+
466
  // TransactionOrHash for union type of transaction and types.Hash
467
  type TransactionOrHash struct {
468
  Hash *common.Hash
 
618
 
619
  // Receipt structure
620
  type Receipt struct {
621
+ Root *common.Hash `json:"root,omitempty"`
622
  CumulativeGasUsed ArgUint64 `json:"cumulativeGasUsed"`
623
  LogsBloom types.Bloom `json:"logsBloom"`
624
  Logs []*types.Log `json:"logs"`
 
660
  return Receipt{}, err
661
  }
662
  receipt := Receipt{
 
663
  CumulativeGasUsed: ArgUint64(r.CumulativeGasUsed),
664
  LogsBloom: r.Bloom,
665
  Logs: logs,
 
675
  Type: ArgUint64(r.Type),
676
  TxL2Hash: l2Hash,
677
  }
678
+ if len(r.PostState) > 0 {
679
+ root := common.BytesToHash(r.PostState)
680
+ receipt.Root = &root
681
+ }
682
+
683
  if r.EffectiveGasPrice != nil {
684
  egp := ArgBig(*r.EffectiveGasPrice)
685
  receipt.EffectiveGasPrice = &egp
{/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree.go RENAMED
@@ -84,16 +84,13 @@
84
  if len(leaves)%2 == 1 {
85
  leaves = append(leaves, mt.zeroHashes[h])
86
  }
87
- if index%2 == 1 { //If it is odd
88
- siblings = append(siblings, leaves[index-1])
89
- } else { // It is even
90
- if len(leaves) > 1 {
91
- if index >= uint32(len(leaves)) {
92
- // siblings = append(siblings, mt.zeroHashes[h])
93
- siblings = append(siblings, leaves[index-1])
94
- } else {
95
- siblings = append(siblings, leaves[index+1])
96
- }
97
  }
98
  }
99
  var (
 
84
  if len(leaves)%2 == 1 {
85
  leaves = append(leaves, mt.zeroHashes[h])
86
  }
87
+ if index >= uint32(len(leaves)) {
88
+ siblings = append(siblings, mt.zeroHashes[h])
89
+ } else {
90
+ if index%2 == 1 { //If it is odd
91
+ siblings = append(siblings, leaves[index-1])
92
+ } else { // It is even
93
+ siblings = append(siblings, leaves[index+1])
 
 
 
94
  }
95
  }
96
  var (
{/home/stefan/go/src/Polygon/zkevm-node → .}/pool/errors.go RENAMED
@@ -76,4 +76,13 @@
76
 
77
  // ErrZeroL1GasPrice is returned if the L1 gas price is 0.
78
  ErrZeroL1GasPrice = errors.New("L1 gas price 0")
 
 
 
 
 
 
 
 
 
79
  )
 
76
 
77
  // ErrZeroL1GasPrice is returned if the L1 gas price is 0.
78
  ErrZeroL1GasPrice = errors.New("L1 gas price 0")
79
+
80
+ // ErrSenderDisallowedSendTx is returned when transactions by sender are is disallowed by policy
81
+ ErrSenderDisallowedSendTx = errors.New("sender disallowed send_tx by policy")
82
+
83
+ // ErrContractDisallowedSendTx is returned when transactions to contract are is disallowed by policy
84
+ ErrContractDisallowedSendTx = errors.New("contract disallowed send_tx by policy")
85
+
86
+ // ErrSenderDisallowedDeploy is returned when deploy transactions are disallowed by policy
87
+ ErrSenderDisallowedDeploy = errors.New("sender disallowed deploy by policy")
88
  )
{/home/stefan/go/src/Polygon/zkevm-node → .}/pool/interfaces.go RENAMED
@@ -38,6 +38,7 @@
38
  MarkWIPTxsAsPending(ctx context.Context) error
39
  GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error)
40
  MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error)
 
41
  GetEarliestProcessedTx(ctx context.Context) (common.Hash, error)
42
  }
43
 
@@ -48,3 +49,12 @@
48
  GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)
49
  PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error)
50
  }
 
 
 
 
 
 
 
 
 
 
38
  MarkWIPTxsAsPending(ctx context.Context) error
39
  GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error)
40
  MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error)
41
+ policy
42
  GetEarliestProcessedTx(ctx context.Context) (common.Hash, error)
43
  }
44
 
 
49
  GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)
50
  PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error)
51
  }
52
+ type policy interface {
53
+ CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error)
54
+ AddAddressesToPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error
55
+ RemoveAddressesFromPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error
56
+ ClearPolicy(ctx context.Context, policy PolicyName) error
57
+ DescribePolicies(ctx context.Context) ([]Policy, error)
58
+ DescribePolicy(ctx context.Context, name PolicyName) (Policy, error)
59
+ ListAcl(ctx context.Context, policy PolicyName, query []common.Address) ([]common.Address, error)
60
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pgpoolstorage/policy.go RENAMED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package pgpoolstorage
2
+
3
+ import (
4
+ "context"
5
+ "errors"
6
+ "fmt"
7
+ "strings"
8
+
9
+ "github.com/0xPolygonHermez/zkevm-node/pool"
10
+ "github.com/ethereum/go-ethereum/common"
11
+ "github.com/jackc/pgx/v4"
12
+ )
13
+
14
+ // CheckPolicy returns the rule for the named policy and address. If the address is associated with the policy, the rule
15
+ // will be the setting for the policy. If the address is no associated with the policy, the rule will be the opposite of
16
+ // the policy setting.
17
+ func (p *PostgresPoolStorage) CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error) {
18
+ sql := `SELECT
19
+ CASE WHEN a.address is null THEN
20
+ NOT p.allow
21
+ ELSE
22
+ p.allow
23
+ END
24
+ FROM pool.policy p
25
+ LEFT JOIN pool.acl a
26
+ ON p.name = a.policy
27
+ AND a.address = $1
28
+ WHERE p.name = $2`
29
+
30
+ rows, err := p.db.Query(ctx, sql, address.Hex(), policy)
31
+
32
+ if errors.Is(err, pgx.ErrNoRows) {
33
+ return false, pool.ErrNotFound
34
+ } else if err != nil {
35
+ return false, err
36
+ }
37
+
38
+ defer rows.Close()
39
+ if !rows.Next() { // should always be a row if the policy exists
40
+ return false, nil
41
+ }
42
+
43
+ var allow bool
44
+ err = rows.Scan(&allow)
45
+ if err != nil {
46
+ return false, err
47
+ }
48
+ return allow, nil
49
+ }
50
+
51
+ // UpdatePolicy sets the allow/deny rule for the named policy
52
+ func (p *PostgresPoolStorage) UpdatePolicy(ctx context.Context, policy pool.PolicyName, allow bool) error {
53
+ sql := "UPDATE pool.policy SET allow = $1 WHERE name = $2"
54
+ _, err := p.db.Exec(ctx, sql, allow, string(policy))
55
+ if err != nil {
56
+ return err
57
+ }
58
+ return nil
59
+ }
60
+
61
+ // AddAddressesToPolicy adds addresses to the named policy
62
+ func (p *PostgresPoolStorage) AddAddressesToPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error {
63
+ sql := "INSERT INTO pool.acl (policy, address) VALUES ($1, $2) ON CONFLICT DO NOTHING"
64
+ tx, err := p.db.Begin(ctx)
65
+ if err != nil {
66
+ return err
67
+ }
68
+ defer func(tx pgx.Tx, ctx context.Context) {
69
+ _ = tx.Rollback(ctx)
70
+ }(tx, ctx)
71
+
72
+ for _, a := range addresses {
73
+ _, err = tx.Exec(ctx, sql, policy, a.Hex())
74
+ if err != nil {
75
+ return err
76
+ }
77
+ }
78
+ err = tx.Commit(ctx)
79
+ if err != nil {
80
+ return nil
81
+ }
82
+ return nil
83
+ }
84
+
85
+ // RemoveAddressesFromPolicy removes addresses from the named policy
86
+ func (p *PostgresPoolStorage) RemoveAddressesFromPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error {
87
+ sql := "DELETE FROM pool.acl WHERE policy = $1 AND address = $2"
88
+ tx, err := p.db.Begin(ctx)
89
+ if err != nil {
90
+ return err
91
+ }
92
+ defer func(tx pgx.Tx, ctx context.Context) {
93
+ _ = tx.Rollback(ctx)
94
+ }(tx, ctx)
95
+
96
+ for _, a := range addresses {
97
+ _, err = tx.Exec(ctx, sql, policy, a.Hex())
98
+ if err != nil {
99
+ return err
100
+ }
101
+ }
102
+ err = tx.Commit(ctx)
103
+ if err != nil {
104
+ return err
105
+ }
106
+ return nil
107
+ }
108
+
109
+ // ClearPolicy removes _all_ addresses from the named policy
110
+ func (p *PostgresPoolStorage) ClearPolicy(ctx context.Context, policy pool.PolicyName) error {
111
+ sql := "DELETE FROM pool.acl WHERE policy = $1"
112
+ _, err := p.db.Exec(ctx, sql, policy)
113
+ if err != nil {
114
+ return err
115
+ }
116
+ return nil
117
+ }
118
+
119
+ // DescribePolicies return all the policies
120
+ func (p *PostgresPoolStorage) DescribePolicies(ctx context.Context) ([]pool.Policy, error) {
121
+ sql := "SELECT name, allow FROM pool.policy"
122
+ rows, err := p.db.Query(ctx, sql)
123
+ if err != nil {
124
+ if errors.Is(err, pgx.ErrNoRows) {
125
+ return nil, nil
126
+ } else {
127
+ return nil, err
128
+ }
129
+ }
130
+ defer rows.Close()
131
+
132
+ var list []pool.Policy
133
+ for rows.Next() {
134
+ var name string
135
+ var allow bool
136
+ err = rows.Scan(&name, &allow)
137
+ if err != nil {
138
+ return nil, err
139
+ }
140
+ if pool.IsPolicy(name) { // skip unknown
141
+ p := pool.Policy{
142
+ Name: pool.PolicyName(name),
143
+ Allow: allow,
144
+ }
145
+ list = append(list, p)
146
+ }
147
+ }
148
+ return list, nil
149
+ }
150
+
151
+ // DescribePolicy returns the named policy
152
+ func (p *PostgresPoolStorage) DescribePolicy(ctx context.Context, name pool.PolicyName) (pool.Policy, error) {
153
+ sql := "SELECT name, allow FROM pool.policy WHERE name = $1 LIMIT 1"
154
+ row := p.db.QueryRow(ctx, sql, name)
155
+ var (
156
+ pName string
157
+ allow bool
158
+ )
159
+ err := row.Scan(&pName, &allow)
160
+ if err != nil {
161
+ return pool.Policy{}, err
162
+ }
163
+ return pool.Policy{
164
+ Name: pool.PolicyName(pName),
165
+ Allow: allow,
166
+ }, nil
167
+ }
168
+
169
+ // ListAcl returns a list of the addresses associated with the policy
170
+ func (p *PostgresPoolStorage) ListAcl(
171
+ ctx context.Context, policy pool.PolicyName, query []common.Address) ([]common.Address, error) {
172
+ sql := "SELECT address FROM pool.acl WHERE policy = $1"
173
+
174
+ if len(query) > 0 {
175
+ var addrs []string
176
+ for _, a := range query {
177
+ addrs = append(addrs, a.Hex())
178
+ }
179
+ sql = sql + fmt.Sprintf(" IN (%v)", strings.Join(addrs, ","))
180
+ }
181
+
182
+ rows, err := p.db.Query(ctx, sql, string(policy))
183
+ if err != nil {
184
+ if errors.Is(err, pgx.ErrNoRows) {
185
+ return nil, nil
186
+ } else {
187
+ return nil, err
188
+ }
189
+ }
190
+ defer rows.Close()
191
+
192
+ var addresses []common.Address
193
+ for rows.Next() {
194
+ var addr string
195
+ err = rows.Scan(&addr)
196
+ if err != nil {
197
+ return nil, err
198
+ }
199
+ addresses = append(addresses, common.HexToAddress(addr))
200
+ }
201
+ return addresses, nil
202
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/pool/policy.go RENAMED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package pool
2
+
3
+ import "github.com/ethereum/go-ethereum/common"
4
+
5
+ // PolicyName is a named policy
6
+ type PolicyName string
7
+
8
+ const (
9
+ // SendTx is the name of the policy that governs that an address may send transactions to pool
10
+ SendTx PolicyName = "send_tx"
11
+ // Deploy is the name of the policy that governs that an address may deploy a contract
12
+ Deploy PolicyName = "deploy"
13
+ )
14
+
15
+ // Policy describes state of a named policy
16
+ type Policy struct {
17
+ Name PolicyName
18
+ Allow bool
19
+ }
20
+
21
+ // Desc returns the string representation of a policy rule
22
+ func (p *Policy) Desc() string {
23
+ if p.Allow {
24
+ return "allow"
25
+ }
26
+ return "deny"
27
+ }
28
+
29
+ // Acl describes exception to a named Policy by address
30
+ type Acl struct {
31
+ PolicyName PolicyName
32
+ Address common.Address
33
+ }
34
+
35
+ // IsPolicy tests if a string represents a known named Policy
36
+ func IsPolicy(name string) bool {
37
+ for _, p := range []PolicyName{SendTx, Deploy} {
38
+ if name == string(p) {
39
+ return true
40
+ }
41
+ }
42
+ return false
43
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool.go RENAMED
@@ -93,6 +93,13 @@
93
  time.Sleep(cfg.IntervalToRefreshGasPrices.Duration)
94
  }
95
  }(&cfg, p)
 
 
 
 
 
 
 
96
 
97
  return p
98
  }
@@ -728,3 +735,8 @@
728
  }
729
  return gas, nil
730
  }
 
 
 
 
 
 
93
  time.Sleep(cfg.IntervalToRefreshGasPrices.Duration)
94
  }
95
  }(&cfg, p)
96
+ p.refreshBlockedAddresses()
97
+ go func(cfg *Config, p *Pool) {
98
+ for {
99
+ time.Sleep(cfg.IntervalToRefreshBlockedAddresses.Duration)
100
+ p.refreshBlockedAddresses()
101
+ }
102
+ }(&cfg, p)
103
 
104
  return p
105
  }
 
735
  }
736
  return gas, nil
737
  }
738
+
739
+ // CheckPolicy checks if an address is allowed by policy name
740
+ func (p *Pool) CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error) {
741
+ return p.storage.CheckPolicy(ctx, policy, address)
742
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool_test.go RENAMED
@@ -2032,3 +2032,69 @@
2032
  require.NoError(t, err)
2033
  return signedTx
2034
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2032
  require.NoError(t, err)
2033
  return signedTx
2034
  }
2035
+
2036
+ func Test_PolicyAcl(t *testing.T) {
2037
+ initOrResetDB(t)
2038
+
2039
+ poolSqlDB, err := db.NewSQLDB(poolDBCfg)
2040
+ require.NoError(t, err)
2041
+ defer poolSqlDB.Close() //nolint:gosec,errcheck
2042
+
2043
+ ctx := context.Background()
2044
+ s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg)
2045
+ require.NoError(t, err)
2046
+
2047
+ p := pool.NewPool(cfg, bc, s, nil, uint64(1), nil)
2048
+
2049
+ randAddr := func() common.Address {
2050
+ buf := make([]byte, 20)
2051
+ _, err = rand.Read(buf)
2052
+ require.NoError(t, err)
2053
+ return common.BytesToAddress(buf)
2054
+ }
2055
+
2056
+ // Policies start out as deny lists, since there are no addresses on the
2057
+ // lists, random addresses will always be allowed
2058
+ for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
2059
+ allow, err := p.CheckPolicy(ctx, policy, randAddr())
2060
+ require.NoError(t, err)
2061
+ require.True(t, allow)
2062
+ }
2063
+
2064
+ addr := randAddr()
2065
+
2066
+ // put addr on lists
2067
+ for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
2068
+ ctag, err := poolSqlDB.Exec(ctx, "INSERT INTO pool.acl (policy, address) VALUES ($1,$2)", policy, addr.Hex())
2069
+ require.NoError(t, err)
2070
+ require.Equal(t, int64(1), ctag.RowsAffected())
2071
+ }
2072
+
2073
+ // addr should not be denied by policy
2074
+ for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
2075
+ allow, err := p.CheckPolicy(ctx, policy, addr)
2076
+ require.NoError(t, err)
2077
+ require.False(t, allow)
2078
+ }
2079
+
2080
+ // change policies to allow by acl
2081
+ ctag, err := poolSqlDB.Exec(ctx, "UPDATE pool.policy SET allow = true")
2082
+ require.NoError(t, err)
2083
+ require.Equal(t, int64(2), ctag.RowsAffected())
2084
+
2085
+ // addr is now allowed
2086
+ for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
2087
+ allow, err := p.CheckPolicy(ctx, policy, addr)
2088
+ require.NoError(t, err)
2089
+ require.True(t, allow)
2090
+ }
2091
+
2092
+ // random addrs are now denied
2093
+ for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
2094
+ for _, a := range []common.Address{randAddr(), randAddr()} {
2095
+ allow, err := s.CheckPolicy(ctx, policy, a)
2096
+ require.NoError(t, err)
2097
+ require.False(t, allow)
2098
+ }
2099
+ }
2100
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/proto/src/proto/executor/v1/executor.proto RENAMED
@@ -292,6 +292,7 @@
292
  // prior to executing the call.
293
  map<string, OverrideAccountV2> state_override = 23;
294
  DebugV2 debug = 24;
 
295
  }
296
 
297
  message L1DataV2 {
@@ -872,4 +873,6 @@
872
  EXECUTOR_ERROR_INVALID_DATA_STREAM = 115;
873
  // EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE indicates that the provided update merkle tree is invalid, e.g. because the executor is configured not to write to database
874
  EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE = 116;
 
 
875
  }
 
292
  // prior to executing the call.
293
  map<string, OverrideAccountV2> state_override = 23;
294
  DebugV2 debug = 24;
295
+ uint64 execution_mode = 25;
296
  }
297
 
298
  message L1DataV2 {
 
873
  EXECUTOR_ERROR_INVALID_DATA_STREAM = 115;
874
  // EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE indicates that the provided update merkle tree is invalid, e.g. because the executor is configured not to write to database
875
  EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE = 116;
876
+ // EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR indicates that a TX has an invalid status-error combination
877
+ EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR = 117;
878
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go RENAMED
@@ -222,11 +222,19 @@
222
 
223
  func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) {
224
  firstL1InfoRootUpdate := true
 
225
 
226
  for {
 
 
 
 
 
 
227
  lastL1BlockNumber, err := f.etherman.GetLatestBlockNumber(ctx)
228
  if err != nil {
229
  log.Errorf("error getting latest L1 block number, error: %v", err)
 
230
  }
231
 
232
  maxBlockNumber := uint64(0)
@@ -246,9 +254,30 @@
246
  }
247
 
248
  if firstL1InfoRootUpdate || l1InfoRoot.L1InfoTreeIndex > f.lastL1InfoTree.L1InfoTreeIndex {
249
- firstL1InfoRootUpdate = false
 
250
 
251
- log.Debugf("received new L1InfoRoot. L1InfoTreeIndex: %d", l1InfoRoot.L1InfoTreeIndex)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
  f.lastL1InfoTreeMux.Lock()
254
  f.lastL1InfoTree = l1InfoRoot
@@ -261,8 +290,6 @@
261
  f.lastL1InfoTreeCond.L.Unlock()
262
  }
263
  }
264
-
265
- time.Sleep(f.cfg.L1InfoTreeCheckInterval.Duration)
266
  }
267
  }
268
 
@@ -363,6 +390,7 @@
363
  SkipWriteBlockInfoRoot_V2: true,
364
  SkipVerifyL1InfoRoot_V2: true,
365
  L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
 
366
  }
367
 
368
  txGasPrice := tx.GasPrice
 
222
 
223
  func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) {
224
  firstL1InfoRootUpdate := true
225
+ skipFirstSleep := true
226
 
227
  for {
228
+ if skipFirstSleep {
229
+ skipFirstSleep = false
230
+ } else {
231
+ time.Sleep(f.cfg.L1InfoTreeCheckInterval.Duration)
232
+ }
233
+
234
  lastL1BlockNumber, err := f.etherman.GetLatestBlockNumber(ctx)
235
  if err != nil {
236
  log.Errorf("error getting latest L1 block number, error: %v", err)
237
+ continue
238
  }
239
 
240
  maxBlockNumber := uint64(0)
 
254
  }
255
 
256
  if firstL1InfoRootUpdate || l1InfoRoot.L1InfoTreeIndex > f.lastL1InfoTree.L1InfoTreeIndex {
257
+ log.Infof("received new L1InfoRoot, l1InfoTreeIndex: %d, l1InfoTreeRoot: %s, l1Block: %d",
258
+ l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.BlockNumber)
259
 
260
+ // Sanity check l1BlockState (l1InfoRoot.BlockNumber) blockhash matches blockhash on ethereum. We skip it if l1InfoRoot.BlockNumber == 0 (empty tree)
261
+ if l1InfoRoot.BlockNumber > 0 {
262
+ l1BlockState, err := f.stateIntf.GetBlockByNumber(ctx, l1InfoRoot.BlockNumber, nil)
263
+ if err != nil {
264
+ log.Errorf("error getting L1 block %d from the state, error: %v", l1InfoRoot.BlockNumber, err)
265
+ continue
266
+ }
267
+
268
+ l1BlockEth, err := f.etherman.HeaderByNumber(ctx, new(big.Int).SetUint64(l1InfoRoot.BlockNumber))
269
+ if err != nil {
270
+ log.Errorf("error getting L1 block %d from ethereum, error: %v", l1InfoRoot.BlockNumber, err)
271
+ continue
272
+ }
273
+ if l1BlockState.BlockHash != l1BlockEth.Hash() {
274
+ log.Warnf("skipping use of l1InfoTreeIndex %d, L1 block %d blockhash %s doesn't match blockhash on ethereum %s (L1 reorg?)",
275
+ l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash())
276
+ continue
277
+ }
278
+ }
279
+
280
+ firstL1InfoRootUpdate = false
281
 
282
  f.lastL1InfoTreeMux.Lock()
283
  f.lastL1InfoTree = l1InfoRoot
 
290
  f.lastL1InfoTreeCond.L.Unlock()
291
  }
292
  }
 
 
293
  }
294
  }
295
 
 
390
  SkipWriteBlockInfoRoot_V2: true,
391
  SkipVerifyL1InfoRoot_V2: true,
392
  L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
393
+ ExecutionMode: executor.ExecutionMode0,
394
  }
395
 
396
  txGasPrice := tx.GasPrice
{/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/interfaces.go RENAMED
@@ -35,6 +35,7 @@
35
  TrustedSequencer() (common.Address, error)
36
  GetLatestBatchNumber() (uint64, error)
37
  GetLatestBlockNumber(ctx context.Context) (uint64, error)
 
38
  }
39
 
40
  // stateInterface gathers the methods required to interact with the state.
 
35
  TrustedSequencer() (common.Address, error)
36
  GetLatestBatchNumber() (uint64, error)
37
  GetLatestBlockNumber(ctx context.Context) (uint64, error)
38
+ HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
39
  }
40
 
41
  // stateInterface gathers the methods required to interact with the state.
{/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go RENAMED
@@ -283,6 +284,7 @@
283
  ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber),
284
  SkipVerifyL1InfoRoot_V2: true,
285
  L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
 
286
  }
287
  batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
288
  GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot,
@@ -582,6 +584,7 @@
582
  SkipFirstChangeL2Block_V2: false,
583
  Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()),
584
  L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
 
585
  }
586
 
587
  batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
 
284
  ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber),
285
  SkipVerifyL1InfoRoot_V2: true,
286
  L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
287
+ ExecutionMode: executor.ExecutionMode0,
288
  }
289
  batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
290
  GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot,
 
584
  SkipFirstChangeL2Block_V2: false,
585
  Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()),
586
  L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
587
+ ExecutionMode: executor.ExecutionMode0,
588
  }
589
 
590
  batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
{/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/config.go RENAMED
@@ -41,4 +41,6 @@
41
  // gas offset: 100
42
  // final gas: 1100
43
  GasOffset uint64 `mapstructure:"GasOffset"`
 
 
44
  }
 
41
  // gas offset: 100
42
  // final gas: 1100
43
  GasOffset uint64 `mapstructure:"GasOffset"`
44
+ // MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx
45
+ MaxBatchesForL1 uint64 `mapstructure:"MaxBatchesForL1"`
46
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/interfaces.go RENAMED
@@ -17,8 +17,8 @@
17
 
18
  // etherman contains the methods required to interact with ethereum.
19
  type etherman interface {
20
- BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error)
21
- EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error)
22
  GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
23
  GetLatestBatchNumber() (uint64, error)
24
  }
@@ -41,3 +41,7 @@
41
  Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error
42
  ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx)
43
  }
 
 
 
 
 
17
 
18
  // etherman contains the methods required to interact with ethereum.
19
  type etherman interface {
20
+ BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (to *common.Address, data []byte, err error)
21
+ EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (*types.Transaction, error)
22
  GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
23
  GetLatestBatchNumber() (uint64, error)
24
  }
 
41
  Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error
42
  ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx)
43
  }
44
+
45
+ type dataAbilitier interface {
46
+ PostSequence(ctx context.Context, sequences []ethmanTypes.Sequence) ([]byte, error)
47
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go RENAMED
@@ -6,13 +6,11 @@
6
  "fmt"
7
  "time"
8
 
9
- ethman "github.com/0xPolygonHermez/zkevm-node/etherman"
10
  "github.com/0xPolygonHermez/zkevm-node/etherman/types"
11
  "github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
12
  "github.com/0xPolygonHermez/zkevm-node/event"
13
  "github.com/0xPolygonHermez/zkevm-node/log"
14
  "github.com/0xPolygonHermez/zkevm-node/state"
15
- ethTypes "github.com/ethereum/go-ethereum/core/types"
16
  "github.com/jackc/pgx/v4"
17
  )
18
 
@@ -41,16 +39,18 @@
41
  ethTxManager ethTxManager
42
  etherman etherman
43
  eventLog *event.EventLog
 
44
  }
45
 
46
  // New inits sequence sender
47
- func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog) (*SequenceSender, error) {
48
  return &SequenceSender{
49
  cfg: cfg,
50
  state: state,
51
  etherman: etherman,
52
  ethTxManager: manager,
53
  eventLog: eventLog,
 
54
  }, nil
55
  }
56
 
@@ -185,9 +185,14 @@
185
  }
186
 
187
  // add sequence to be monitored
188
- firstSequence := sequences[0]
 
 
 
 
189
 
190
- to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase)
 
191
  if err != nil {
192
  log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err)
193
  return
@@ -218,8 +223,6 @@
218
  sequences := []types.Sequence{}
219
  // var estimatedGas uint64
220
 
221
- var tx *ethTypes.Transaction
222
-
223
  // Add sequences until too big for a single L1 tx or last batch is reached
224
  for {
225
  //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to
@@ -288,31 +291,11 @@
288
 
289
  sequences = append(sequences, seq)
290
  // Check if can be send
291
- firstSequence := sequences[0]
292
- lastSequence := sequences[len(sequences)-1]
293
- tx, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase)
294
- if err == nil && tx.Size() > s.cfg.MaxTxSizeForL1 {
295
- log.Infof("oversized Data on TX oldHash %s (txSize %d > %d)", tx.Hash(), tx.Size(), s.cfg.MaxTxSizeForL1)
296
- err = ErrOversizedData
297
- }
298
- if err != nil {
299
- log.Infof("Handling estimage gas send sequence error: %v", err)
300
- sequences, err = s.handleEstimateGasSendSequenceErr(ctx, sequences, currentBatchNumToSequence, err)
301
- if sequences != nil {
302
- if len(sequences) > 0 {
303
- // Handling the error gracefully, re-processing the sequence as a sanity check
304
- lastSequence = sequences[len(sequences)-1]
305
- _, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase)
306
- return sequences, err
307
- }
308
- }
309
- return sequences, err
310
- }
311
- // estimatedGas = tx.Gas()
312
-
313
- //Check if the current batch is the last before a change to a new forkid, in this case we need to close and send the sequence to L1
314
- if (s.cfg.ForkUpgradeBatchNumber != 0) && (currentBatchNumToSequence == (s.cfg.ForkUpgradeBatchNumber)) {
315
- log.Infof("sequence should be sent to L1, as we have reached the batch %d from which a new forkid is applied (upgrade)", s.cfg.ForkUpgradeBatchNumber)
316
  return sequences, nil
317
  }
318
 
@@ -343,78 +326,6 @@
343
  return nil, nil
344
  }
345
 
346
- // handleEstimateGasSendSequenceErr handles an error on the estimate gas. It will return:
347
- // nil, error: impossible to handle gracefully
348
- // sequence, nil: handled gracefully. Potentially manipulating the sequences
349
- // nil, nil: a situation that requires waiting
350
- func (s *SequenceSender) handleEstimateGasSendSequenceErr(
351
- ctx context.Context,
352
- sequences []types.Sequence,
353
- currentBatchNumToSequence uint64,
354
- err error,
355
- ) ([]types.Sequence, error) {
356
- // Insufficient allowance
357
- if errors.Is(err, ethman.ErrInsufficientAllowance) {
358
- return nil, err
359
- }
360
- if isDataForEthTxTooBig(err) {
361
- // Remove the latest item and send the sequences
362
- log.Infof(
363
- "Done building sequences, selected batches to %d. Batch %d caused the L1 tx to be too big",
364
- currentBatchNumToSequence-1, currentBatchNumToSequence,
365
- )
366
- sequences = sequences[:len(sequences)-1]
367
- return sequences, nil
368
- }
369
-
370
- // while estimating gas a new block is not created and the POE SC may return
371
- // an error regarding timestamp verification, this must be handled
372
- // if errors.Is(err, ethman.ErrTimestampMustBeInsideRange) {
373
- // // query the sc about the value of its lastTimestamp variable
374
- // lastTimestamp, err := s.etherman.GetLastBatchTimestamp()
375
- // if err != nil {
376
- // return nil, err
377
- // }
378
- // // check POE SC lastTimestamp against sequences' one
379
- // for _, seq := range sequences {
380
- // if seq.Timestamp < int64(lastTimestamp) {
381
- // // TODO: gracefully handle this situation by creating an L2 reorg
382
- // log.Fatalf("sequence timestamp %d is < POE SC lastTimestamp %d", seq.Timestamp, lastTimestamp)
383
- // }
384
- // lastTimestamp = uint64(seq.Timestamp)
385
- // }
386
- // blockTimestamp, err := s.etherman.GetLatestBlockTimestamp(ctx)
387
- // if err != nil {
388
- // log.Error("error getting block timestamp: ", err)
389
- // }
390
- // log.Debugf("block.timestamp: %d is smaller than seq.Timestamp: %d. A new block must be mined in L1 before the gas can be estimated.", blockTimestamp, sequences[0].Timestamp)
391
- // return nil, nil
392
- // }
393
-
394
- // Unknown error
395
- if len(sequences) == 1 {
396
- // TODO: gracefully handle this situation by creating an L2 reorg
397
- log.Errorf(
398
- "Error when estimating gas for BatchNum %d (alone in the sequences): %v",
399
- currentBatchNumToSequence, err,
400
- )
401
- }
402
- // Remove the latest item and send the sequences
403
- log.Infof(
404
- "Done building sequences, selected batches to %d. Batch %d excluded due to unknown error: %v",
405
- currentBatchNumToSequence, currentBatchNumToSequence+1, err,
406
- )
407
- sequences = sequences[:len(sequences)-1]
408
-
409
- return sequences, nil
410
- }
411
-
412
- func isDataForEthTxTooBig(err error) bool {
413
- return errors.Is(err, ethman.ErrGasRequiredExceedsAllowance) ||
414
- errors.Is(err, ErrOversizedData) ||
415
- errors.Is(err, ethman.ErrContentLengthTooLarge)
416
- }
417
-
418
  func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) {
419
  lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil)
420
  if err != nil && err != state.ErrNotFound {
 
6
  "fmt"
7
  "time"
8
 
 
9
  "github.com/0xPolygonHermez/zkevm-node/etherman/types"
10
  "github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
11
  "github.com/0xPolygonHermez/zkevm-node/event"
12
  "github.com/0xPolygonHermez/zkevm-node/log"
13
  "github.com/0xPolygonHermez/zkevm-node/state"
 
14
  "github.com/jackc/pgx/v4"
15
  )
16
 
 
39
  ethTxManager ethTxManager
40
  etherman etherman
41
  eventLog *event.EventLog
42
+ da dataAbilitier
43
  }
44
 
45
  // New inits sequence sender
46
+ func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog, da dataAbilitier) (*SequenceSender, error) {
47
  return &SequenceSender{
48
  cfg: cfg,
49
  state: state,
50
  etherman: etherman,
51
  ethTxManager: manager,
52
  eventLog: eventLog,
53
+ da: da,
54
  }, nil
55
  }
56
 
 
185
  }
186
 
187
  // add sequence to be monitored
188
+ dataAvailabilityMessage, err := s.da.PostSequence(ctx, sequences)
189
+ if err != nil {
190
+ log.Error("error posting sequences to the data availability protocol: ", err)
191
+ return
192
+ }
193
 
194
+ firstSequence := sequences[0]
195
+ to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase, dataAvailabilityMessage)
196
  if err != nil {
197
  log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err)
198
  return
 
223
  sequences := []types.Sequence{}
224
  // var estimatedGas uint64
225
 
 
 
226
  // Add sequences until too big for a single L1 tx or last batch is reached
227
  for {
228
  //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to
 
291
 
292
  sequences = append(sequences, seq)
293
  // Check if can be send
294
+ if len(sequences) == int(s.cfg.MaxBatchesForL1) {
295
+ log.Info(
296
+ "sequence should be sent to L1, because MaxBatchesForL1 (%d) has been reached",
297
+ s.cfg.MaxBatchesForL1,
298
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  return sequences, nil
300
  }
301
 
 
326
  return nil, nil
327
  }
328
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) {
330
  lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil)
331
  if err != nil && err != state.ErrNotFound {
{/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender_test.go RENAMED
@@ -30,7 +30,7 @@
30
  stateMock := new(StateMock)
31
  ethermanMock := new(EthermanMock)
32
  ethTxManagerMock := new(EthTxManagerMock)
33
- ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil)
34
  assert.NoError(t, err)
35
 
36
  testCases := []IsSyncedTestCase{
 
30
  stateMock := new(StateMock)
31
  ethermanMock := new(EthermanMock)
32
  ethTxManagerMock := new(EthTxManagerMock)
33
+ ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil, nil)
34
  assert.NoError(t, err)
35
 
36
  testCases := []IsSyncedTestCase{
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2.go RENAMED
@@ -69,6 +69,7 @@
69
  ChainId: s.cfg.ChainID,
70
  ForkId: request.ForkID,
71
  ContextId: uuid.NewString(),
 
72
  }
73
 
74
  if request.SkipFirstChangeL2Block_V2 {
@@ -131,6 +132,7 @@
131
  ForkId: forkId,
132
  ContextId: uuid.NewString(),
133
  SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot,
 
134
  }
135
 
136
  if forcedBlockHashL1 != nil {
@@ -231,6 +233,7 @@
231
  ContextId: uuid.NewString(),
232
  SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot,
233
  L1InfoRoot: processingCtx.L1InfoRoot.Bytes(),
 
234
  }
235
 
236
  if processingCtx.ForcedBlockHashL1 != nil {
@@ -307,6 +310,7 @@
307
  log.Warn(batchResponseToString)
308
  s.eventLog.LogExecutorErrorV2(ctx, batchResponse.Error, batchRequest)
309
  } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) {
 
310
  log.Warnf("executor batch %d response, ROM OOC, error: %v", newBatchNum, err)
311
  log.Warn(batchResponseToString)
312
  } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR {
 
69
  ChainId: s.cfg.ChainID,
70
  ForkId: request.ForkID,
71
  ContextId: uuid.NewString(),
72
+ ExecutionMode: request.ExecutionMode,
73
  }
74
 
75
  if request.SkipFirstChangeL2Block_V2 {
 
132
  ForkId: forkId,
133
  ContextId: uuid.NewString(),
134
  SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot,
135
+ ExecutionMode: executor.ExecutionMode1,
136
  }
137
 
138
  if forcedBlockHashL1 != nil {
 
233
  ContextId: uuid.NewString(),
234
  SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot,
235
  L1InfoRoot: processingCtx.L1InfoRoot.Bytes(),
236
+ ExecutionMode: processingCtx.ExecutionMode,
237
  }
238
 
239
  if processingCtx.ForcedBlockHashL1 != nil {
 
310
  log.Warn(batchResponseToString)
311
  s.eventLog.LogExecutorErrorV2(ctx, batchResponse.Error, batchRequest)
312
  } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) {
313
+ err = executor.RomErr(batchResponse.ErrorRom)
314
  log.Warnf("executor batch %d response, ROM OOC, error: %v", newBatchNum, err)
315
  log.Warn(batchResponseToString)
316
  } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR {
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/convertersV2.go RENAMED
@@ -127,6 +127,7 @@
127
  result.ReturnValue = response.ReturnValue
128
  result.GasLeft = response.GasLeft
129
  result.GasUsed = response.GasUsed
 
130
  result.GasRefunded = response.GasRefunded
131
  result.RomError = executor.RomErr(response.Error)
132
  result.CreateAddress = common.HexToAddress(response.CreateAddress)
 
127
  result.ReturnValue = response.ReturnValue
128
  result.GasLeft = response.GasLeft
129
  result.GasUsed = response.GasUsed
130
+ result.CumulativeGasUsed = response.CumulativeGasUsed
131
  result.GasRefunded = response.GasRefunded
132
  result.RomError = executor.RomErr(response.Error)
133
  result.CreateAddress = common.HexToAddress(response.CreateAddress)
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/datastream.go RENAMED
@@ -118,6 +118,7 @@
118
  // DSL2Transaction represents a data stream L2 transaction
119
  type DSL2Transaction struct {
120
  L2BlockNumber uint64 // Not included in the encoded data
 
121
  EffectiveGasPricePercentage uint8 // 1 byte
122
  IsValid uint8 // 1 byte
123
  StateRoot common.Hash // 32 bytes
@@ -553,6 +554,9 @@
553
  }
554
 
555
  for _, tx := range l2Block.Txs {
 
 
 
556
  if l2Block.ForkID < FORKID_ETROG {
557
  // Populate intermediate state root with information from the system SC (or cache if available)
558
  if imStateRoots == nil || (*imStateRoots)[blockStart.L2BlockNumber] == nil {
@@ -565,6 +569,8 @@
565
  } else {
566
  tx.StateRoot = common.BytesToHash((*imStateRoots)[blockStart.L2BlockNumber])
567
  }
 
 
568
  }
569
 
570
  _, err = streamServer.AddStreamEntry(EntryTypeL2Tx, tx.Encode())
 
118
  // DSL2Transaction represents a data stream L2 transaction
119
  type DSL2Transaction struct {
120
  L2BlockNumber uint64 // Not included in the encoded data
121
+ ImStateRoot common.Hash // Not included in the encoded data
122
  EffectiveGasPricePercentage uint8 // 1 byte
123
  IsValid uint8 // 1 byte
124
  StateRoot common.Hash // 32 bytes
 
554
  }
555
 
556
  for _, tx := range l2Block.Txs {
557
+ // < ETROG => IM State root is retrieved from the system SC (using cache is available)
558
+ // = ETROG => IM State root is retrieved from the receipt.post_state => Do nothing
559
+ // > ETROG => IM State root is retrieved from the receipt.im_state_root
560
  if l2Block.ForkID < FORKID_ETROG {
561
  // Populate intermediate state root with information from the system SC (or cache if available)
562
  if imStateRoots == nil || (*imStateRoots)[blockStart.L2BlockNumber] == nil {
 
569
  } else {
570
  tx.StateRoot = common.BytesToHash((*imStateRoots)[blockStart.L2BlockNumber])
571
  }
572
+ } else if l2Block.ForkID > FORKID_ETROG {
573
+ tx.StateRoot = tx.ImStateRoot
574
  }
575
 
576
  _, err = streamServer.AddStreamEntry(EntryTypeL2Tx, tx.Encode())
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/forkid.go RENAMED
@@ -17,6 +17,8 @@
17
  FORKID_ETROG = 7
18
  // FORKID_ELDERBERRY is the fork id 8
19
  FORKID_ELDERBERRY = 8
 
 
20
  )
21
 
22
  // ForkIDInterval is a fork id interval
 
17
  FORKID_ETROG = 7
18
  // FORKID_ELDERBERRY is the fork id 8
19
  FORKID_ELDERBERRY = 8
20
+ // FORKID_9 is the fork id 9
21
+ FORKID_9 = 9
22
  )
23
 
24
  // ForkIDInterval is a fork id interval
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/genesis.go RENAMED
@@ -19,8 +19,10 @@
19
 
20
  // Genesis contains the information to populate state on creation
21
  type Genesis struct {
22
- // BlockNumber is the block number where the polygonZKEVM smc was deployed on L1
23
- BlockNumber uint64
 
 
24
  // Root hash of the genesis block
25
  Root common.Hash
26
  // Actions is the data to populate into the state trie
@@ -204,7 +206,7 @@
204
  storeTxsEGPData := []StoreTxEGPData{}
205
  txsL2Hash := []common.Hash{}
206
 
207
- err = s.AddL2Block(ctx, batch.BatchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, dbTx)
208
  if err != nil {
209
  return common.Hash{}, err
210
  }
 
19
 
20
  // Genesis contains the information to populate state on creation
21
  type Genesis struct {
22
+ // RollupBlockNumber is the block number where the polygonZKEVM smc was deployed on L1
23
+ RollupBlockNumber uint64
24
+ // RollupManagerBlockNumber is the block number where the RollupManager smc was deployed on L1
25
+ RollupManagerBlockNumber uint64
26
  // Root hash of the genesis block
27
  Root common.Hash
28
  // Actions is the data to populate into the state trie
 
206
  storeTxsEGPData := []StoreTxEGPData{}
207
  txsL2Hash := []common.Hash{}
208
 
209
+ err = s.AddL2Block(ctx, batch.BatchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, []common.Hash{}, dbTx)
210
  if err != nil {
211
  return common.Hash{}, err
212
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/helper.go RENAMED
@@ -279,19 +279,23 @@
279
  }
280
 
281
  // GenerateReceipt generates a receipt from a processed transaction
282
- func GenerateReceipt(blockNumber *big.Int, processedTx *ProcessTransactionResponse, txIndex uint) *types.Receipt {
283
  receipt := &types.Receipt{
284
- Type: uint8(processedTx.Type),
285
- PostState: processedTx.StateRoot.Bytes(),
286
- CumulativeGasUsed: processedTx.GasUsed,
287
- BlockNumber: blockNumber,
288
- GasUsed: processedTx.GasUsed,
289
- TxHash: processedTx.Tx.Hash(),
290
- TransactionIndex: txIndex,
291
- ContractAddress: processedTx.CreateAddress,
292
- Logs: processedTx.Logs,
 
 
 
 
 
293
  }
294
-
295
  if processedTx.EffectiveGasPrice != "" {
296
  effectiveGasPrice, ok := big.NewInt(0).SetString(processedTx.EffectiveGasPrice, 0)
297
  if !ok {
@@ -309,10 +313,14 @@
309
  for i := 0; i < len(receipt.Logs); i++ {
310
  receipt.Logs[i].TxHash = processedTx.Tx.Hash()
311
  }
312
- if processedTx.RomError == nil {
313
- receipt.Status = types.ReceiptStatusSuccessful
 
 
 
 
314
  } else {
315
- receipt.Status = types.ReceiptStatusFailed
316
  }
317
 
318
  return receipt
 
279
  }
280
 
281
  // GenerateReceipt generates a receipt from a processed transaction
282
+ func GenerateReceipt(blockNumber *big.Int, processedTx *ProcessTransactionResponse, txIndex uint, forkID uint64) *types.Receipt {
283
  receipt := &types.Receipt{
284
+ Type: uint8(processedTx.Type),
285
+ BlockNumber: blockNumber,
286
+ GasUsed: processedTx.GasUsed,
287
+ TxHash: processedTx.Tx.Hash(),
288
+ TransactionIndex: txIndex,
289
+ ContractAddress: processedTx.CreateAddress,
290
+ Logs: processedTx.Logs,
291
+ }
292
+ if forkID <= FORKID_ETROG {
293
+ receipt.PostState = processedTx.StateRoot.Bytes()
294
+ receipt.CumulativeGasUsed = processedTx.GasUsed
295
+ } else {
296
+ receipt.PostState = []byte{}
297
+ receipt.CumulativeGasUsed = processedTx.CumulativeGasUsed
298
  }
 
299
  if processedTx.EffectiveGasPrice != "" {
300
  effectiveGasPrice, ok := big.NewInt(0).SetString(processedTx.EffectiveGasPrice, 0)
301
  if !ok {
 
313
  for i := 0; i < len(receipt.Logs); i++ {
314
  receipt.Logs[i].TxHash = processedTx.Tx.Hash()
315
  }
316
+ if forkID <= FORKID_ETROG {
317
+ if processedTx.RomError == nil {
318
+ receipt.Status = types.ReceiptStatusSuccessful
319
+ } else {
320
+ receipt.Status = types.ReceiptStatusFailed
321
+ }
322
  } else {
323
+ receipt.Status = uint64(processedTx.Status)
324
  }
325
 
326
  return receipt
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go RENAMED
@@ -72,7 +72,7 @@
72
  GetL2BlockTransactionCountByHash(ctx context.Context, blockHash common.Hash, dbTx pgx.Tx) (uint64, error)
73
  GetL2BlockTransactionCountByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error)
74
  GetTransactionEGPLogByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*EffectiveGasPriceLog, error)
75
- AddL2Block(ctx context.Context, batchNumber uint64, l2Block *L2Block, receipts []*types.Receipt, txsL2Hash []common.Hash, txsEGPData []StoreTxEGPData, dbTx pgx.Tx) error
76
  GetLastVirtualizedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
77
  GetLastConsolidatedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
78
  GetLastVerifiedL2BlockNumberUntilL1Block(ctx context.Context, l1FinalizedBlockNumber uint64, dbTx pgx.Tx) (uint64, error)
@@ -93,7 +93,7 @@
93
  IsL2BlockConsolidated(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)
94
  IsL2BlockVirtualized(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)
95
  GetLogs(ctx context.Context, fromBlock uint64, toBlock uint64, addresses []common.Address, topics [][]common.Hash, blockHash *common.Hash, since *time.Time, dbTx pgx.Tx) ([]*types.Log, error)
96
- AddReceipt(ctx context.Context, receipt *types.Receipt, dbTx pgx.Tx) error
97
  AddLog(ctx context.Context, l *types.Log, dbTx pgx.Tx) error
98
  GetExitRootByGlobalExitRoot(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*GlobalExitRoot, error)
99
  AddSequence(ctx context.Context, sequence Sequence, dbTx pgx.Tx) error
@@ -121,7 +121,8 @@
121
  GetBatchByForcedBatchNum(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (*Batch, error)
122
  AddForkID(ctx context.Context, forkID ForkIDInterval, dbTx pgx.Tx) error
123
  GetForkIDs(ctx context.Context, dbTx pgx.Tx) ([]ForkIDInterval, error)
124
- UpdateForkID(ctx context.Context, forkID ForkIDInterval, dbTx pgx.Tx) error
 
125
  GetNativeBlockHashesInRange(ctx context.Context, fromBlock, toBlock uint64, dbTx pgx.Tx) ([]common.Hash, error)
126
  GetDSGenesisBlock(ctx context.Context, dbTx pgx.Tx) (*DSL2Block, error)
127
  GetDSBatches(ctx context.Context, firstBatchNumber, lastBatchNumber uint64, readWIPBatch bool, dbTx pgx.Tx) ([]*DSBatch, error)
@@ -149,6 +150,8 @@
149
  GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error)
150
  GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error)
151
  GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error)
 
 
152
  GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
153
  GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error)
154
  GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error)
 
72
  GetL2BlockTransactionCountByHash(ctx context.Context, blockHash common.Hash, dbTx pgx.Tx) (uint64, error)
73
  GetL2BlockTransactionCountByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error)
74
  GetTransactionEGPLogByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*EffectiveGasPriceLog, error)
75
+ AddL2Block(ctx context.Context, batchNumber uint64, l2Block *L2Block, receipts []*types.Receipt, txsL2Hash []common.Hash, txsEGPData []StoreTxEGPData, imStateRoots []common.Hash, dbTx pgx.Tx) error
76
  GetLastVirtualizedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
77
  GetLastConsolidatedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
78
  GetLastVerifiedL2BlockNumberUntilL1Block(ctx context.Context, l1FinalizedBlockNumber uint64, dbTx pgx.Tx) (uint64, error)
 
93
  IsL2BlockConsolidated(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)
94
  IsL2BlockVirtualized(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error)
95
  GetLogs(ctx context.Context, fromBlock uint64, toBlock uint64, addresses []common.Address, topics [][]common.Hash, blockHash *common.Hash, since *time.Time, dbTx pgx.Tx) ([]*types.Log, error)
96
+ AddReceipt(ctx context.Context, receipt *types.Receipt, imStateRoot common.Hash, dbTx pgx.Tx) error
97
  AddLog(ctx context.Context, l *types.Log, dbTx pgx.Tx) error
98
  GetExitRootByGlobalExitRoot(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*GlobalExitRoot, error)
99
  AddSequence(ctx context.Context, sequence Sequence, dbTx pgx.Tx) error
 
121
  GetBatchByForcedBatchNum(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (*Batch, error)
122
  AddForkID(ctx context.Context, forkID ForkIDInterval, dbTx pgx.Tx) error
123
  GetForkIDs(ctx context.Context, dbTx pgx.Tx) ([]ForkIDInterval, error)
124
+ UpdateForkIDToBatchNumber(ctx context.Context, forkID ForkIDInterval, dbTx pgx.Tx) error
125
+ UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error
126
  GetNativeBlockHashesInRange(ctx context.Context, fromBlock, toBlock uint64, dbTx pgx.Tx) ([]common.Hash, error)
127
  GetDSGenesisBlock(ctx context.Context, dbTx pgx.Tx) (*DSL2Block, error)
128
  GetDSBatches(ctx context.Context, firstBatchNumber, lastBatchNumber uint64, readWIPBatch bool, dbTx pgx.Tx) ([]*DSBatch, error)
 
150
  GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error)
151
  GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error)
152
  GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error)
153
+ GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error)
154
+ GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
155
  GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
156
  GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error)
157
  GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error)
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/datastream.go RENAMED
@@ -91,7 +91,7 @@
91
 
92
  // GetDSL2Transactions returns the L2 transactions
93
  func (p *PostgresStorage) GetDSL2Transactions(ctx context.Context, firstL2Block, lastL2Block uint64, dbTx pgx.Tx) ([]*state.DSL2Transaction, error) {
94
- const l2TxSQL = `SELECT l2_block_num, t.effective_percentage, t.encoded, r.post_state
95
  FROM state.transaction t, state.receipt r
96
  WHERE l2_block_num BETWEEN $1 AND $2 AND r.tx_hash = t.hash
97
  ORDER BY t.l2_block_num ASC, r.tx_index ASC`
@@ -120,11 +120,13 @@
120
  l2Transaction := state.DSL2Transaction{}
121
  encoded := []byte{}
122
  postState := []byte{}
 
123
  if err := row.Scan(
124
  &l2Transaction.L2BlockNumber,
125
  &l2Transaction.EffectiveGasPricePercentage,
126
  &encoded,
127
  &postState,
 
128
  ); err != nil {
129
  return nil, err
130
  }
@@ -142,6 +144,7 @@
142
  l2Transaction.EncodedLength = uint32(len(l2Transaction.Encoded))
143
  l2Transaction.IsValid = 1
144
  l2Transaction.StateRoot = common.BytesToHash(postState)
 
145
  return &l2Transaction, nil
146
  }
147
 
 
91
 
92
  // GetDSL2Transactions returns the L2 transactions
93
  func (p *PostgresStorage) GetDSL2Transactions(ctx context.Context, firstL2Block, lastL2Block uint64, dbTx pgx.Tx) ([]*state.DSL2Transaction, error) {
94
+ const l2TxSQL = `SELECT l2_block_num, t.effective_percentage, t.encoded, r.post_state, r.im_state_root
95
  FROM state.transaction t, state.receipt r
96
  WHERE l2_block_num BETWEEN $1 AND $2 AND r.tx_hash = t.hash
97
  ORDER BY t.l2_block_num ASC, r.tx_index ASC`
 
120
  l2Transaction := state.DSL2Transaction{}
121
  encoded := []byte{}
122
  postState := []byte{}
123
+ imStateRoot := []byte{}
124
  if err := row.Scan(
125
  &l2Transaction.L2BlockNumber,
126
  &l2Transaction.EffectiveGasPricePercentage,
127
  &encoded,
128
  &postState,
129
+ &imStateRoot,
130
  ); err != nil {
131
  return nil, err
132
  }
 
144
  l2Transaction.EncodedLength = uint32(len(l2Transaction.Encoded))
145
  l2Transaction.IsValid = 1
146
  l2Transaction.StateRoot = common.BytesToHash(postState)
147
+ l2Transaction.ImStateRoot = common.BytesToHash(imStateRoot)
148
  return &l2Transaction, nil
149
  }
150
 
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/forkid.go RENAMED
@@ -51,7 +51,7 @@
51
  }
52
 
53
  // UpdateForkID updates the forkID stored in db
54
- func (p *PostgresStorage) UpdateForkID(ctx context.Context, forkID state.ForkIDInterval, dbTx pgx.Tx) error {
55
  const updateForkIDSQL = "UPDATE state.fork_id SET to_batch_num = $1 WHERE fork_id = $2"
56
  e := p.getExecQuerier(dbTx)
57
  if _, err := e.Exec(ctx, updateForkIDSQL, forkID.ToBatchNumber, forkID.ForkId); err != nil {
@@ -60,6 +60,25 @@
60
  return nil
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  // UpdateForkIDIntervalsInMemory updates the forkID intervals in memory
64
  func (p *PostgresStorage) UpdateForkIDIntervalsInMemory(intervals []state.ForkIDInterval) {
65
  log.Infof("Updating forkIDs. Setting %d forkIDs", len(intervals))
@@ -88,7 +107,7 @@
88
  return err
89
  }
90
  forkIDs[len(forkIDs)-1].ToBatchNumber = newForkID.FromBatchNumber - 1
91
- err := p.UpdateForkID(ctx, forkIDs[len(forkIDs)-1], dbTx)
92
  if err != nil {
93
  log.Errorf("error updating forkID: %d. Error: %v", forkIDs[len(forkIDs)-1].ForkId, err)
94
  return err
 
51
  }
52
 
53
  // UpdateForkID updates the forkID stored in db
54
+ func (p *PostgresStorage) UpdateForkIDToBatchNumber(ctx context.Context, forkID state.ForkIDInterval, dbTx pgx.Tx) error {
55
  const updateForkIDSQL = "UPDATE state.fork_id SET to_batch_num = $1 WHERE fork_id = $2"
56
  e := p.getExecQuerier(dbTx)
57
  if _, err := e.Exec(ctx, updateForkIDSQL, forkID.ToBatchNumber, forkID.ForkId); err != nil {
 
60
  return nil
61
  }
62
 
63
+ // UpdateForkID updates the forkID stored in db
64
+ func (p *PostgresStorage) UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error {
65
+ const sql = "UPDATE state.fork_id SET block_num = $1 WHERE fork_id = $2"
66
+ e := p.getExecQuerier(dbTx)
67
+ if _, err := e.Exec(ctx, sql, forkdID, newBlockNumber); err != nil {
68
+ return err
69
+ }
70
+ if updateMemCache {
71
+ log.Debugf("Updating forkID %d in memory", forkdID)
72
+ forkIDs, err := p.GetForkIDs(ctx, dbTx)
73
+ if err != nil {
74
+ log.Error("error getting oldForkIDs. Error: ", err)
75
+ return err
76
+ }
77
+ p.UpdateForkIDIntervalsInMemory(forkIDs)
78
+ }
79
+ return nil
80
+ }
81
+
82
  // UpdateForkIDIntervalsInMemory updates the forkID intervals in memory
83
  func (p *PostgresStorage) UpdateForkIDIntervalsInMemory(intervals []state.ForkIDInterval) {
84
  log.Infof("Updating forkIDs. Setting %d forkIDs", len(intervals))
 
107
  return err
108
  }
109
  forkIDs[len(forkIDs)-1].ToBatchNumber = newForkID.FromBatchNumber - 1
110
+ err := p.UpdateForkIDToBatchNumber(ctx, forkIDs[len(forkIDs)-1], dbTx)
111
  if err != nil {
112
  log.Errorf("error updating forkID: %d. Error: %v", forkIDs[len(forkIDs)-1].ForkId, err)
113
  return err
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l2block.go RENAMED
@@ -169,8 +169,8 @@
169
  }
170
 
171
  // AddL2Block adds a new L2 block to the State Store
172
- func (p *PostgresStorage) AddL2Block(ctx context.Context, batchNumber uint64, l2Block *state.L2Block, receipts []*types.Receipt, txsL2Hash []common.Hash, txsEGPData []state.StoreTxEGPData, dbTx pgx.Tx) error {
173
- //TODO: Optmize this function using only one SQL (with several values) to insert all the txs, receips and logs
174
  log.Debugf("[AddL2Block] adding L2 block %d", l2Block.NumberU64())
175
  start := time.Now()
176
 
@@ -255,7 +255,7 @@
255
  }
256
 
257
  if len(receipts) > 0 {
258
- p.AddReceipts(ctx, receipts, dbTx)
259
 
260
  var logs []*types.Log
261
  for _, receipt := range receipts {
 
169
  }
170
 
171
  // AddL2Block adds a new L2 block to the State Store
172
+ func (p *PostgresStorage) AddL2Block(ctx context.Context, batchNumber uint64, l2Block *state.L2Block, receipts []*types.Receipt, txsL2Hash []common.Hash, txsEGPData []state.StoreTxEGPData, imStateRoots []common.Hash, dbTx pgx.Tx) error {
173
+ // TODO: Optimize this function using only one SQL (with several values) to insert all the txs, receipts and logs
174
  log.Debugf("[AddL2Block] adding L2 block %d", l2Block.NumberU64())
175
  start := time.Now()
176
 
 
255
  }
256
 
257
  if len(receipts) > 0 {
258
+ p.AddReceipts(ctx, receipts, imStateRoots, dbTx)
259
 
260
  var logs []*types.Log
261
  for _, receipt := range receipts {
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage.go RENAMED
@@ -355,3 +355,49 @@
355
  }
356
  return nativeBlockHashes, nil
357
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  }
356
  return nativeBlockHashes, nil
357
  }
358
+
359
+ // GetBatchL2DataByNumber returns the batch L2 data of the given batch number.
360
+ func (p *PostgresStorage) GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) {
361
+ batchData, err := p.GetBatchL2DataByNumbers(ctx, []uint64{batchNumber}, dbTx)
362
+ if err != nil {
363
+ return nil, err
364
+ }
365
+ data, ok := batchData[batchNumber]
366
+ if !ok {
367
+ return nil, state.ErrNotFound
368
+ }
369
+ return data, nil
370
+ }
371
+
372
+ // GetBatchL2DataByNumbers returns the batch L2 data of the given batch numbers. The data is a union of state.batch and state.forced_batch tables.
373
+ func (p *PostgresStorage) GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) {
374
+ const getBatchL2DataByBatchNumber = `
375
+ SELECT batch_num, raw_txs_data FROM state.batch WHERE batch_num = ANY($1)
376
+ UNION
377
+ SELECT forced_batch_num, convert_from(decode(raw_txs_data, 'hex'), 'UTF8')::bytea FROM state.forced_batch WHERE forced_batch_num = ANY($2)
378
+ `
379
+ q := p.getExecQuerier(dbTx)
380
+ rows, err := q.Query(ctx, getBatchL2DataByBatchNumber, batchNumbers, batchNumbers)
381
+ if errors.Is(err, pgx.ErrNoRows) {
382
+ return nil, state.ErrNotFound
383
+ } else if err != nil {
384
+ return nil, err
385
+ }
386
+ defer rows.Close()
387
+ batchL2DataMap := make(map[uint64][]byte)
388
+ for rows.Next() {
389
+ var (
390
+ batchNum uint64
391
+ batchL2Data []byte
392
+ )
393
+ err := rows.Scan(&batchNum, &batchL2Data)
394
+ if err != nil {
395
+ return nil, err
396
+ }
397
+ batchL2DataMap[batchNum] = batchL2Data
398
+ }
399
+ if len(batchL2DataMap) == 0 {
400
+ return nil, state.ErrNotFound
401
+ }
402
+ return batchL2DataMap, nil
403
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go RENAMED
@@ -188,6 +188,7 @@
188
  transactions := []*types.Transaction{tx}
189
 
190
  receipts := []*types.Receipt{receipt}
 
191
 
192
  // Create block to be able to calculate its hash
193
  st := trie.NewStackTrie(nil)
@@ -202,7 +203,7 @@
202
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
203
  }
204
 
205
- err = pgStateStorage.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, dbTx)
206
  require.NoError(t, err)
207
  result, err := pgStateStorage.BatchNumberByL2BlockNumber(ctx, l2Block.Number().Uint64(), dbTx)
208
  require.NoError(t, err)
@@ -657,7 +658,7 @@
657
  require.Equal(t, forks[i].Version, forkId.Version)
658
  }
659
  forkID3.ToBatchNumber = 18446744073709551615
660
- err = testState.UpdateForkID(ctx, forkID3, dbTx)
661
  require.NoError(t, err)
662
 
663
  forkIDs, err = testState.GetForkIDs(ctx, dbTx)
@@ -724,7 +725,7 @@
724
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
725
  }
726
 
727
- err = testState.AddL2Block(ctx, batchNumber, l2Block, []*types.Receipt{}, txsL2Hash, storeTxsEGPData, dbTx)
728
  require.NoError(t, err)
729
 
730
  virtualBatch := state.VirtualBatch{BlockNumber: blockNumber, BatchNumber: batchNumber, Coinbase: addr, SequencerAddr: addr, TxHash: hash}
@@ -923,6 +924,7 @@
923
 
924
  transactions := []*types.Transaction{tx}
925
  receipts := []*types.Receipt{receipt}
 
926
 
927
  header := state.NewL2Header(&types.Header{
928
  Number: big.NewInt(int64(i) + 1),
@@ -948,7 +950,7 @@
948
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
949
  }
950
 
951
- err = testState.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, dbTx)
952
  require.NoError(t, err)
953
  }
954
 
@@ -1054,6 +1056,7 @@
1054
 
1055
  transactions := []*types.Transaction{tx}
1056
  receipts := []*types.Receipt{receipt}
 
1057
 
1058
  header := state.NewL2Header(&types.Header{
1059
  Number: big.NewInt(int64(i) + 1),
@@ -1079,7 +1082,7 @@
1079
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
1080
  }
1081
 
1082
- err = testState.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, dbTx)
1083
  require.NoError(t, err)
1084
 
1085
  nativeBlockHashes = append(nativeBlockHashes, l2Block.Header().Root)
@@ -1129,6 +1132,82 @@
1129
  require.NoError(t, dbTx.Commit(ctx))
1130
  }
1131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1132
  func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry {
1133
  exitRoot := state.L1InfoTreeExitRootStorageEntry{
1134
  L1InfoTreeLeaf: state.L1InfoTreeLeaf{
@@ -1330,6 +1409,10 @@
1330
  require.Equal(t, uint64(2002), fb.BlockNumber)
1331
  require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String())
1332
  require.Equal(t, []byte{0xb}, fb.RawTxsData)
 
 
 
 
1333
  }
1334
 
1335
  func TestGetLastGER(t *testing.T) {
@@ -1406,5 +1489,4 @@
1406
  ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx)
1407
  require.NoError(t, err)
1408
  require.Equal(t, common.HexToHash("0x2").String(), ger.String())
1409
-
1410
  }
 
188
  transactions := []*types.Transaction{tx}
189
 
190
  receipts := []*types.Receipt{receipt}
191
+ imStateRoots := []common.Hash{state.ZeroHash}
192
 
193
  // Create block to be able to calculate its hash
194
  st := trie.NewStackTrie(nil)
 
203
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
204
  }
205
 
206
+ err = pgStateStorage.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx)
207
  require.NoError(t, err)
208
  result, err := pgStateStorage.BatchNumberByL2BlockNumber(ctx, l2Block.Number().Uint64(), dbTx)
209
  require.NoError(t, err)
 
658
  require.Equal(t, forks[i].Version, forkId.Version)
659
  }
660
  forkID3.ToBatchNumber = 18446744073709551615
661
+ err = testState.UpdateForkIDToBatchNumber(ctx, forkID3, dbTx)
662
  require.NoError(t, err)
663
 
664
  forkIDs, err = testState.GetForkIDs(ctx, dbTx)
 
725
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
726
  }
727
 
728
+ err = testState.AddL2Block(ctx, batchNumber, l2Block, []*types.Receipt{}, txsL2Hash, storeTxsEGPData, []common.Hash{}, dbTx)
729
  require.NoError(t, err)
730
 
731
  virtualBatch := state.VirtualBatch{BlockNumber: blockNumber, BatchNumber: batchNumber, Coinbase: addr, SequencerAddr: addr, TxHash: hash}
 
924
 
925
  transactions := []*types.Transaction{tx}
926
  receipts := []*types.Receipt{receipt}
927
+ stateRoots := []common.Hash{state.ZeroHash}
928
 
929
  header := state.NewL2Header(&types.Header{
930
  Number: big.NewInt(int64(i) + 1),
 
950
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
951
  }
952
 
953
+ err = testState.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, stateRoots, dbTx)
954
  require.NoError(t, err)
955
  }
956
 
 
1056
 
1057
  transactions := []*types.Transaction{tx}
1058
  receipts := []*types.Receipt{receipt}
1059
+ stateRoots := []common.Hash{state.ZeroHash}
1060
 
1061
  header := state.NewL2Header(&types.Header{
1062
  Number: big.NewInt(int64(i) + 1),
 
1082
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
1083
  }
1084
 
1085
+ err = testState.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, stateRoots, dbTx)
1086
  require.NoError(t, err)
1087
 
1088
  nativeBlockHashes = append(nativeBlockHashes, l2Block.Header().Root)
 
1132
  require.NoError(t, dbTx.Commit(ctx))
1133
  }
1134
 
1135
+ func TestGetBatchL2DataByNumber(t *testing.T) {
1136
+ // Init database instance
1137
+ initOrResetDB()
1138
+ ctx := context.Background()
1139
+ tx, err := testState.BeginStateTransaction(ctx)
1140
+ require.NoError(t, err)
1141
+ defer func() { require.NoError(t, tx.Commit(ctx)) }()
1142
+
1143
+ // empty case
1144
+ var batchNum uint64 = 4
1145
+ const openBatchSQL = "INSERT INTO state.batch (batch_num, raw_txs_data, wip) VALUES ($1, $2, false)"
1146
+ _, err = tx.Exec(ctx, openBatchSQL, batchNum, nil)
1147
+ require.NoError(t, err)
1148
+ data, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
1149
+ require.NoError(t, err)
1150
+ assert.Nil(t, data)
1151
+
1152
+ // not empty case
1153
+ expectedData := []byte("foo bar")
1154
+ batchNum = 5
1155
+ _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData)
1156
+ require.NoError(t, err)
1157
+ actualData, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
1158
+ require.NoError(t, err)
1159
+ assert.Equal(t, expectedData, actualData)
1160
+
1161
+ multiGet := []uint64{uint64(4), uint64(5), uint64(6)}
1162
+ allData, err := testState.GetBatchL2DataByNumbers(ctx, multiGet, tx)
1163
+ require.NoError(t, err)
1164
+ require.Equal(t, expectedData, allData[uint64(5)])
1165
+ }
1166
+
1167
+ func TestGetBatchL2DataByNumbers(t *testing.T) {
1168
+ initOrResetDB()
1169
+ ctx := context.Background()
1170
+ tx, err := testState.BeginStateTransaction(ctx)
1171
+ require.NoError(t, err)
1172
+ defer func() { require.NoError(t, tx.Commit(ctx)) }()
1173
+
1174
+ var i1, i2, i3, i4, i5 = uint64(1), uint64(2), uint64(3), uint64(4), uint64(5)
1175
+ var d1, d2, d4 = []byte("foobar"), []byte("dingbat"), []byte{0xb}
1176
+
1177
+ const insertBatch = "INSERT INTO state.batch (batch_num, raw_txs_data) VALUES ($1, $2)"
1178
+ _, err = tx.Exec(ctx, insertBatch, i1, d1)
1179
+ require.NoError(t, err)
1180
+ _, err = tx.Exec(ctx, insertBatch, i2, d2)
1181
+ require.NoError(t, err)
1182
+ _, err = tx.Exec(ctx, insertBatch, i3, nil)
1183
+ require.NoError(t, err)
1184
+
1185
+ // Add a forced batch too, needs a block
1186
+ block1 := *block
1187
+ block1.BlockNumber = 1000
1188
+ err = testState.AddBlock(ctx, &block1, tx)
1189
+ require.NoError(t, err)
1190
+ err = tx.Commit(ctx)
1191
+ require.NoError(t, err)
1192
+
1193
+ tx, err = testState.BeginStateTransaction(ctx)
1194
+ require.NoError(t, err)
1195
+
1196
+ const insertForcedBatch = "INSERT INTO state.forced_batch (forced_batch_num, timestamp, raw_txs_data, block_num) VALUES (4, now(),'0b', 1000)"
1197
+ _, err = testState.Exec(ctx, insertForcedBatch)
1198
+ require.NoError(t, err)
1199
+
1200
+ allData, err := testState.GetBatchL2DataByNumbers(ctx, []uint64{i1, i2, i3, i4, i5}, tx)
1201
+ require.NoError(t, err)
1202
+ assert.Equal(t, d1, allData[i1])
1203
+ assert.Equal(t, d2, allData[i2])
1204
+ assert.Nil(t, allData[i3])
1205
+ assert.Equal(t, d4, allData[i4])
1206
+
1207
+ _, ok := allData[i5]
1208
+ assert.False(t, ok)
1209
+ }
1210
+
1211
  func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry {
1212
  exitRoot := state.L1InfoTreeExitRootStorageEntry{
1213
  L1InfoTreeLeaf: state.L1InfoTreeLeaf{
 
1409
  require.Equal(t, uint64(2002), fb.BlockNumber)
1410
  require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String())
1411
  require.Equal(t, []byte{0xb}, fb.RawTxsData)
1412
+
1413
+ fbData, err := testState.GetBatchL2DataByNumber(ctx, 1, dbTx)
1414
+ require.NoError(t, err)
1415
+ require.Equal(t, []byte{0xb}, fbData)
1416
  }
1417
 
1418
  func TestGetLastGER(t *testing.T) {
 
1489
  ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx)
1490
  require.NoError(t, err)
1491
  require.Equal(t, common.HexToHash("0x2").String(), ger.String())
 
1492
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/transaction.go RENAMED
@@ -515,7 +515,7 @@
515
  }
516
 
517
  // AddReceipt adds a new receipt to the State Store
518
- func (p *PostgresStorage) AddReceipt(ctx context.Context, receipt *types.Receipt, dbTx pgx.Tx) error {
519
  e := p.getExecQuerier(dbTx)
520
 
521
  var effectiveGasPrice *uint64
@@ -526,31 +526,31 @@
526
  }
527
 
528
  const addReceiptSQL = `
529
- INSERT INTO state.receipt (tx_hash, type, post_state, status, cumulative_gas_used, gas_used, effective_gas_price, block_num, tx_index, contract_address)
530
- VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`
531
- _, err := e.Exec(ctx, addReceiptSQL, receipt.TxHash.String(), receipt.Type, receipt.PostState, receipt.Status, receipt.CumulativeGasUsed, receipt.GasUsed, effectiveGasPrice, receipt.BlockNumber.Uint64(), receipt.TransactionIndex, receipt.ContractAddress.String())
532
  return err
533
  }
534
 
535
  // AddReceipts adds a list of receipts to the State Store
536
- func (p *PostgresStorage) AddReceipts(ctx context.Context, receipts []*types.Receipt, dbTx pgx.Tx) error {
537
  if len(receipts) == 0 {
538
  return nil
539
  }
540
 
541
  receiptRows := [][]interface{}{}
542
 
543
- for _, receipt := range receipts {
544
  var egp uint64
545
  if receipt.EffectiveGasPrice != nil {
546
  egp = receipt.EffectiveGasPrice.Uint64()
547
  }
548
- receiptRow := []interface{}{receipt.TxHash.String(), receipt.Type, receipt.PostState, receipt.Status, receipt.CumulativeGasUsed, receipt.GasUsed, egp, receipt.BlockNumber.Uint64(), receipt.TransactionIndex, receipt.ContractAddress.String()}
549
  receiptRows = append(receiptRows, receiptRow)
550
  }
551
 
552
  _, err := dbTx.CopyFrom(ctx, pgx.Identifier{"state", "receipt"},
553
- []string{"tx_hash", "type", "post_state", "status", "cumulative_gas_used", "gas_used", "effective_gas_price", "block_num", "tx_index", "contract_address"},
554
  pgx.CopyFromRows(receiptRows))
555
 
556
  return err
 
515
  }
516
 
517
  // AddReceipt adds a new receipt to the State Store
518
+ func (p *PostgresStorage) AddReceipt(ctx context.Context, receipt *types.Receipt, imStateRoot common.Hash, dbTx pgx.Tx) error {
519
  e := p.getExecQuerier(dbTx)
520
 
521
  var effectiveGasPrice *uint64
 
526
  }
527
 
528
  const addReceiptSQL = `
529
+ INSERT INTO state.receipt (tx_hash, type, post_state, status, cumulative_gas_used, gas_used, effective_gas_price, block_num, tx_index, contract_address, im_state_root)
530
+ VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)`
531
+ _, err := e.Exec(ctx, addReceiptSQL, receipt.TxHash.String(), receipt.Type, receipt.PostState, receipt.Status, receipt.CumulativeGasUsed, receipt.GasUsed, effectiveGasPrice, receipt.BlockNumber.Uint64(), receipt.TransactionIndex, receipt.ContractAddress.String(), imStateRoot.Bytes())
532
  return err
533
  }
534
 
535
  // AddReceipts adds a list of receipts to the State Store
536
+ func (p *PostgresStorage) AddReceipts(ctx context.Context, receipts []*types.Receipt, imStateRoots []common.Hash, dbTx pgx.Tx) error {
537
  if len(receipts) == 0 {
538
  return nil
539
  }
540
 
541
  receiptRows := [][]interface{}{}
542
 
543
+ for i, receipt := range receipts {
544
  var egp uint64
545
  if receipt.EffectiveGasPrice != nil {
546
  egp = receipt.EffectiveGasPrice.Uint64()
547
  }
548
+ receiptRow := []interface{}{receipt.TxHash.String(), receipt.Type, receipt.PostState, receipt.Status, receipt.CumulativeGasUsed, receipt.GasUsed, egp, receipt.BlockNumber.Uint64(), receipt.TransactionIndex, receipt.ContractAddress.String(), imStateRoots[i].Bytes()}
549
  receiptRows = append(receiptRows, receiptRow)
550
  }
551
 
552
  _, err := dbTx.CopyFrom(ctx, pgx.Identifier{"state", "receipt"},
553
+ []string{"tx_hash", "type", "post_state", "status", "cumulative_gas_used", "gas_used", "effective_gas_price", "block_num", "tx_index", "contract_address", "im_state_root"},
554
  pgx.CopyFromRows(receiptRows))
555
 
556
  return err
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/client.go RENAMED
@@ -10,6 +10,13 @@
10
  "google.golang.org/grpc/credentials/insecure"
11
  )
12
 
 
 
 
 
 
 
 
13
  // NewExecutorClient is the executor client constructor.
14
  func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) {
15
  opts := []grpc.DialOption{
 
10
  "google.golang.org/grpc/credentials/insecure"
11
  )
12
 
13
+ const (
14
+ // ExecutionMode0 is the execution mode for the sequencer and RPC, default one
15
+ ExecutionMode0 = uint64(0)
16
+ // ExecutionMode1 is the execution mode for the synchronizer
17
+ ExecutionMode1 = uint64(1)
18
+ )
19
+
20
  // NewExecutorClient is the executor client constructor.
21
  func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) {
22
  opts := []grpc.DialOption{
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/errors.go RENAMED
@@ -454,6 +454,8 @@
454
  return runtime.ErrExecutorErrorInvalidDataStream
455
  case ExecutorError_EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE:
456
  return runtime.ErrExecutorErrorInvalidUpdateMerkleTree
 
 
457
  }
458
  return ErrExecutorUnknown
459
  }
@@ -694,6 +696,8 @@
694
  return ExecutorError_EXECUTOR_ERROR_INVALID_DATA_STREAM
695
  case runtime.ErrExecutorErrorInvalidUpdateMerkleTree:
696
  return ExecutorError_EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE
 
 
697
  }
698
 
699
  return ErrCodeExecutorUnknown
 
454
  return runtime.ErrExecutorErrorInvalidDataStream
455
  case ExecutorError_EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE:
456
  return runtime.ErrExecutorErrorInvalidUpdateMerkleTree
457
+ case ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR:
458
+ return runtime.ErrExecutorErrorSMMainInvalidTxStatusError
459
  }
460
  return ErrExecutorUnknown
461
  }
 
696
  return ExecutorError_EXECUTOR_ERROR_INVALID_DATA_STREAM
697
  case runtime.ErrExecutorErrorInvalidUpdateMerkleTree:
698
  return ExecutorError_EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE
699
+ case runtime.ErrExecutorErrorSMMainInvalidTxStatusError:
700
+ return ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR
701
  }
702
 
703
  return ErrCodeExecutorUnknown
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/runtime.go RENAMED
@@ -319,6 +319,8 @@
319
  ErrExecutorErrorInvalidDataStream = errors.New("invalid data stream")
320
  // ErrExecutorErrorInvalidUpdateMerkleTree indicates that the input parameter update merkle tree is invalid
321
  ErrExecutorErrorInvalidUpdateMerkleTree = errors.New("invalid update merkle tree")
 
 
322
 
323
  // GRPC ERRORS
324
  // ===========
 
319
  ErrExecutorErrorInvalidDataStream = errors.New("invalid data stream")
320
  // ErrExecutorErrorInvalidUpdateMerkleTree indicates that the input parameter update merkle tree is invalid
321
  ErrExecutorErrorInvalidUpdateMerkleTree = errors.New("invalid update merkle tree")
322
+ // ErrExecutorErrorSMMainInvalidTxStatusError indicates that the TX has an invalid status-error combination
323
+ ErrExecutorErrorSMMainInvalidTxStatusError = errors.New("tx has an invalid status-error combination")
324
 
325
  // GRPC ERRORS
326
  // ===========
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/test/forkid_dragonfruit/dragonfruit_test.go RENAMED
@@ -1486,6 +1486,7 @@
1486
  })
1487
 
1488
  receipts := []*types.Receipt{receipt, receipt1}
 
1489
 
1490
  transactions := []*types.Transaction{signedTx0, signedTx1}
1491
 
@@ -1505,7 +1506,7 @@
1505
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
1506
  }
1507
 
1508
- err = testState.AddL2Block(ctx, 0, l2Block, receipts, txsL2Hash, storeTxsEGPData, dbTx)
1509
  require.NoError(t, err)
1510
  l2Block, err = testState.GetL2BlockByHash(ctx, l2Block.Hash(), dbTx)
1511
  require.NoError(t, err)
 
1486
  })
1487
 
1488
  receipts := []*types.Receipt{receipt, receipt1}
1489
+ imStateRoots := []common.Hash{common.BytesToHash(processBatchResponse.Responses[0].StateRoot), common.BytesToHash(processBatchResponse.Responses[1].StateRoot)}
1490
 
1491
  transactions := []*types.Transaction{signedTx0, signedTx1}
1492
 
 
1506
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
1507
  }
1508
 
1509
+ err = testState.AddL2Block(ctx, 0, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx)
1510
  require.NoError(t, err)
1511
  l2Block, err = testState.GetL2BlockByHash(ctx, l2Block.Hash(), dbTx)
1512
  require.NoError(t, err)
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/test/forkid_independent/independent_test.go RENAMED
@@ -643,6 +643,7 @@
643
  transactions := []*types.Transaction{tx}
644
 
645
  receipts := []*types.Receipt{receipt}
 
646
 
647
  // Create block to be able to calculate its hash
648
  st := trie.NewStackTrie(nil)
@@ -659,7 +660,7 @@
659
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
660
  }
661
 
662
- err = testState.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, dbTx)
663
  require.NoError(t, err)
664
  result, err := testState.GetL2BlockByHash(ctx, l2Block.Hash(), dbTx)
665
  require.NoError(t, err)
 
643
  transactions := []*types.Transaction{tx}
644
 
645
  receipts := []*types.Receipt{receipt}
646
+ imStateRoots := []common.Hash{state.ZeroHash}
647
 
648
  // Create block to be able to calculate its hash
649
  st := trie.NewStackTrie(nil)
 
660
  txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
661
  }
662
 
663
+ err = testState.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx)
664
  require.NoError(t, err)
665
  result, err := testState.GetL2BlockByHash(ctx, l2Block.Hash(), dbTx)
666
  require.NoError(t, err)
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/trace.go RENAMED
@@ -61,11 +61,22 @@
61
  }
62
  oldStateRoot = previousL2Block.Root()
63
 
 
 
 
 
 
 
 
 
 
 
 
64
  // since the executor only stores the state roots by block, we need to
65
  // execute all the txs in the block until the tx we want to trace
66
  var txsToEncode []types.Transaction
67
  var effectivePercentage []uint8
68
- for i := 0; i <= int(receipt.TransactionIndex); i++ {
69
  txsToEncode = append(txsToEncode, *l2Block.Transactions()[i])
70
  effectivePercentage = append(effectivePercentage, MaxEffectivePercentage)
71
  log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String())
@@ -188,41 +199,50 @@
188
  }
189
  }
190
 
191
- // build the raw batch so we can get the index l1 info tree for the l2 block
192
- rawBatch, err := DecodeBatchV2(batch.BatchL2Data)
193
- if err != nil {
194
- log.Errorf("error decoding BatchL2Data for batch %d, error: %v", batch.BatchNumber, err)
195
- return nil, err
196
- }
 
 
 
 
 
 
 
 
 
197
 
198
- // identify the first l1 block number so we can identify the
199
- // current l2 block index in the block array
200
- firstBlockNumberForBatch, err := s.GetFirstL2BlockNumberForBatchNumber(ctx, batch.BatchNumber, dbTx)
201
- if err != nil {
202
- log.Errorf("failed to get first l2 block number for batch %v: %v ", batch.BatchNumber, err)
203
- return nil, err
204
- }
205
 
206
- // computes the l2 block index
207
- rawL2BlockIndex := l2Block.NumberU64() - firstBlockNumberForBatch
208
- if rawL2BlockIndex > uint64(len(rawBatch.Blocks)-1) {
209
- log.Errorf("computed rawL2BlockIndex is greater than the number of blocks we have in the batch %v: %v ", batch.BatchNumber, err)
210
- return nil, err
211
- }
212
 
213
- // builds the ChangeL2Block transaction with the correct timestamp and IndexL1InfoTree
214
- rawL2Block := rawBatch.Blocks[rawL2BlockIndex]
215
- deltaTimestamp := uint32(l2Block.Time() - previousL2Block.Time())
216
- transactions := s.BuildChangeL2Block(deltaTimestamp, rawL2Block.IndexL1InfoTree)
 
 
 
 
 
 
217
 
218
- batchL2Data, err := EncodeTransactions(txsToEncode, effectivePercentage, forkId)
219
- if err != nil {
220
- log.Errorf("error encoding transaction ", err)
221
- return nil, err
222
  }
223
-
224
- transactions = append(transactions, batchL2Data...)
225
-
226
  // prepare process batch request
227
  processBatchRequestV2 := &executor.ProcessBatchRequestV2{
228
  OldBatchNum: batch.BatchNumber - 1,
@@ -242,6 +262,7 @@
242
  TimestampLimit: uint64(time.Now().Unix()),
243
  SkipFirstChangeL2Block: cFalse,
244
  SkipWriteBlockInfoRoot: cTrue,
 
245
  }
246
 
247
  // gets the L1InfoTreeData for the transactions
@@ -263,6 +284,79 @@
263
  }
264
  }
265
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  // Send Batch to the Executor
267
  startTime = time.Now()
268
  processBatchResponseV2, err := s.executorClient.ProcessBatchV2(ctx, processBatchRequestV2)
@@ -275,15 +369,16 @@
275
  return nil, err
276
  }
277
 
278
- // Transactions are decoded only for logging purposes
279
- // as they are not longer needed in the convertToProcessBatchResponse function
280
- txs, _, _, err := DecodeTxs(batchL2Data, forkId)
281
- if err != nil && !errors.Is(err, ErrInvalidData) {
282
- return nil, err
283
- }
284
-
285
- for _, tx := range txs {
286
- log.Debugf(tx.Hash().String())
 
287
  }
288
 
289
  convertedResponse, err := s.convertToProcessBatchResponseV2(processBatchResponseV2)
 
61
  }
62
  oldStateRoot = previousL2Block.Root()
63
 
64
+ count := 0
65
+ for _, tx := range l2Block.Transactions() {
66
+ checkReceipt, err := s.GetTransactionReceipt(ctx, tx.Hash(), dbTx)
67
+ if err != nil {
68
+ return nil, err
69
+ }
70
+ if checkReceipt.TransactionIndex < receipt.TransactionIndex {
71
+ count++
72
+ }
73
+ }
74
+
75
  // since the executor only stores the state roots by block, we need to
76
  // execute all the txs in the block until the tx we want to trace
77
  var txsToEncode []types.Transaction
78
  var effectivePercentage []uint8
79
+ for i := 0; i <= count; i++ {
80
  txsToEncode = append(txsToEncode, *l2Block.Transactions()[i])
81
  effectivePercentage = append(effectivePercentage, MaxEffectivePercentage)
82
  log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String())
 
199
  }
200
  }
201
 
202
+ // if the l2 block number is 1, it means this is a network that started
203
+ // at least on Etrog fork, in this case the l2 block 1 will contain the
204
+ // injected tx that needs to be processed in a different way
205
+ isInjectedTx := l2Block.NumberU64() == 1
206
+
207
+ var transactions, batchL2Data []byte
208
+ if isInjectedTx {
209
+ transactions = append([]byte{}, batch.BatchL2Data...)
210
+ } else {
211
+ // build the raw batch so we can get the index l1 info tree for the l2 block
212
+ rawBatch, err := DecodeBatchV2(batch.BatchL2Data)
213
+ if err != nil {
214
+ log.Errorf("error decoding BatchL2Data for batch %d, error: %v", batch.BatchNumber, err)
215
+ return nil, err
216
+ }
217
 
218
+ // identify the first l1 block number so we can identify the
219
+ // current l2 block index in the block array
220
+ firstBlockNumberForBatch, err := s.GetFirstL2BlockNumberForBatchNumber(ctx, batch.BatchNumber, dbTx)
221
+ if err != nil {
222
+ log.Errorf("failed to get first l2 block number for batch %v: %v ", batch.BatchNumber, err)
223
+ return nil, err
224
+ }
225
 
226
+ // computes the l2 block index
227
+ rawL2BlockIndex := l2Block.NumberU64() - firstBlockNumberForBatch
228
+ if rawL2BlockIndex > uint64(len(rawBatch.Blocks)-1) {
229
+ log.Errorf("computed rawL2BlockIndex is greater than the number of blocks we have in the batch %v: %v ", batch.BatchNumber, err)
230
+ return nil, err
231
+ }
232
 
233
+ // builds the ChangeL2Block transaction with the correct timestamp and IndexL1InfoTree
234
+ rawL2Block := rawBatch.Blocks[rawL2BlockIndex]
235
+ deltaTimestamp := uint32(l2Block.Time() - previousL2Block.Time())
236
+ transactions = s.BuildChangeL2Block(deltaTimestamp, rawL2Block.IndexL1InfoTree)
237
+
238
+ batchL2Data, err = EncodeTransactions(txsToEncode, effectivePercentage, forkId)
239
+ if err != nil {
240
+ log.Errorf("error encoding transaction ", err)
241
+ return nil, err
242
+ }
243
 
244
+ transactions = append(transactions, batchL2Data...)
 
 
 
245
  }
 
 
 
246
  // prepare process batch request
247
  processBatchRequestV2 := &executor.ProcessBatchRequestV2{
248
  OldBatchNum: batch.BatchNumber - 1,
 
262
  TimestampLimit: uint64(time.Now().Unix()),
263
  SkipFirstChangeL2Block: cFalse,
264
  SkipWriteBlockInfoRoot: cTrue,
265
+ ExecutionMode: executor.ExecutionMode0,
266
  }
267
 
268
  // gets the L1InfoTreeData for the transactions
 
284
  }
285
  }
286
 
287
+ // gets the L1InfoTreeData for the transactions
288
+ l1InfoTreeData, _, _, err = s.GetL1InfoTreeDataFromBatchL2Data(ctx, transactions, dbTx)
289
+ if err != nil {
290
+ return nil, err
291
+ }
292
+
293
+ // In case we have any l1InfoTreeData, add them to the request
294
+ if len(l1InfoTreeData) > 0 {
295
+ processBatchRequestV2.L1InfoTreeData = map[uint32]*executor.L1DataV2{}
296
+ processBatchRequestV2.SkipVerifyL1InfoRoot = cTrue
297
+ for k, v := range l1InfoTreeData {
298
+ processBatchRequestV2.L1InfoTreeData[k] = &executor.L1DataV2{
299
+ GlobalExitRoot: v.GlobalExitRoot.Bytes(),
300
+ BlockHashL1: v.BlockHashL1.Bytes(),
301
+ MinTimestamp: v.MinTimestamp,
302
+ }
303
+ }
304
+ }
305
+
306
+ // gets the L1InfoTreeData for the transactions
307
+ l1InfoTreeData, _, _, err = s.GetL1InfoTreeDataFromBatchL2Data(ctx, transactions, dbTx)
308
+ if err != nil {
309
+ return nil, err
310
+ }
311
+
312
+ // In case we have any l1InfoTreeData, add them to the request
313
+ if len(l1InfoTreeData) > 0 {
314
+ processBatchRequestV2.L1InfoTreeData = map[uint32]*executor.L1DataV2{}
315
+ processBatchRequestV2.SkipVerifyL1InfoRoot = cTrue
316
+ for k, v := range l1InfoTreeData {
317
+ processBatchRequestV2.L1InfoTreeData[k] = &executor.L1DataV2{
318
+ GlobalExitRoot: v.GlobalExitRoot.Bytes(),
319
+ BlockHashL1: v.BlockHashL1.Bytes(),
320
+ MinTimestamp: v.MinTimestamp,
321
+ }
322
+ }
323
+ }
324
+
325
+ if isInjectedTx {
326
+ virtualBatch, err := s.GetVirtualBatch(ctx, batch.BatchNumber, dbTx)
327
+ if err != nil {
328
+ log.Errorf("failed to load virtual batch %v", batch.BatchNumber, err)
329
+ return nil, err
330
+ }
331
+ l1Block, err := s.GetBlockByNumber(ctx, virtualBatch.BlockNumber, dbTx)
332
+ if err != nil {
333
+ log.Errorf("failed to load l1 block %v", virtualBatch.BlockNumber, err)
334
+ return nil, err
335
+ }
336
+
337
+ processBatchRequestV2.ForcedBlockhashL1 = l1Block.BlockHash.Bytes()
338
+ processBatchRequestV2.SkipVerifyL1InfoRoot = 1
339
+ } else {
340
+ // gets the L1InfoTreeData for the transactions
341
+ l1InfoTreeData, _, _, err := s.GetL1InfoTreeDataFromBatchL2Data(ctx, transactions, dbTx)
342
+ if err != nil {
343
+ return nil, err
344
+ }
345
+
346
+ // In case we have any l1InfoTreeData, add them to the request
347
+ if len(l1InfoTreeData) > 0 {
348
+ processBatchRequestV2.L1InfoTreeData = map[uint32]*executor.L1DataV2{}
349
+ processBatchRequestV2.SkipVerifyL1InfoRoot = cTrue
350
+ for k, v := range l1InfoTreeData {
351
+ processBatchRequestV2.L1InfoTreeData[k] = &executor.L1DataV2{
352
+ GlobalExitRoot: v.GlobalExitRoot.Bytes(),
353
+ BlockHashL1: v.BlockHashL1.Bytes(),
354
+ MinTimestamp: v.MinTimestamp,
355
+ }
356
+ }
357
+ }
358
+ }
359
+
360
  // Send Batch to the Executor
361
  startTime = time.Now()
362
  processBatchResponseV2, err := s.executorClient.ProcessBatchV2(ctx, processBatchRequestV2)
 
369
  return nil, err
370
  }
371
 
372
+ if !isInjectedTx {
373
+ // Transactions are decoded only for logging purposes
374
+ // as they are no longer needed in the convertToProcessBatchResponse function
375
+ txs, _, _, err := DecodeTxs(batchL2Data, forkId)
376
+ if err != nil && !errors.Is(err, ErrInvalidData) {
377
+ return nil, err
378
+ }
379
+ for _, tx := range txs {
380
+ log.Debugf(tx.Hash().String())
381
+ }
382
  }
383
 
384
  convertedResponse, err := s.convertToProcessBatchResponseV2(processBatchResponseV2)
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go RENAMED
@@ -117,6 +117,8 @@
117
  return ErrBatchAlreadyClosed
118
  }
119
 
 
 
120
  for _, processedBlock := range processedBlocks {
121
  processedTxs := processedBlock.TransactionResponses
122
  // check existing txs vs parameter txs
@@ -167,11 +169,12 @@
167
  header.BlockInfoRoot = processedBlock.BlockInfoRoot
168
  transactions := []*types.Transaction{&processedTx.Tx}
169
 
170
- receipt := GenerateReceipt(header.Number, processedTx, uint(i))
171
  if !CheckLogOrder(receipt.Logs) {
172
  return fmt.Errorf("error: logs received from executor are not in order")
173
  }
174
  receipts := []*types.Receipt{receipt}
 
175
 
176
  // Create l2Block to be able to calculate its hash
177
  st := trie.NewStackTrie(nil)
@@ -187,7 +190,7 @@
187
  txsL2Hash := []common.Hash{processedTx.TxHashL2_V2}
188
 
189
  // Store L2 block and its transaction
190
- if err := s.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, dbTx); err != nil {
191
  return err
192
  }
193
  }
@@ -209,8 +212,11 @@
209
  return err
210
  }
211
 
 
 
212
  gasLimit := l2Block.GasLimit
213
- if gasLimit > MaxL2BlockGasLimit {
 
214
  gasLimit = MaxL2BlockGasLimit
215
  }
216
 
@@ -234,6 +240,8 @@
234
  storeTxsEGPData := make([]StoreTxEGPData, 0, numTxs)
235
  receipts := make([]*types.Receipt, 0, numTxs)
236
  txsL2Hash := make([]common.Hash, 0, numTxs)
 
 
237
 
238
  for i, txResponse := range l2Block.TransactionResponses {
239
  // if the transaction has an intrinsic invalid tx error it means
@@ -244,11 +252,9 @@
244
  if executor.IsInvalidL2Block(executor.RomErrorCode(txResponse.RomError)) {
245
  continue
246
  }
247
-
248
  txResp := *txResponse
249
  transactions = append(transactions, &txResp.Tx)
250
  txsL2Hash = append(txsL2Hash, txResp.TxHashL2_V2)
251
-
252
  storeTxEGPData := StoreTxEGPData{EGPLog: nil, EffectivePercentage: uint8(txResponse.EffectivePercentage)}
253
  if txsEGPLog != nil {
254
  storeTxEGPData.EGPLog = txsEGPLog[i]
@@ -256,8 +262,9 @@
256
 
257
  storeTxsEGPData = append(storeTxsEGPData, storeTxEGPData)
258
 
259
- receipt := GenerateReceipt(header.Number, txResponse, uint(i))
260
  receipts = append(receipts, receipt)
 
261
  }
262
 
263
  // Create block to be able to calculate its hash
@@ -270,7 +277,7 @@
270
  }
271
 
272
  // Store L2 block and its transactions
273
- if err := s.AddL2Block(ctx, batchNumber, block, receipts, txsL2Hash, storeTxsEGPData, dbTx); err != nil {
274
  return err
275
  }
276
 
@@ -529,6 +536,7 @@
529
  TimestampLimit: uint64(time.Now().Unix()),
530
  SkipFirstChangeL2Block: cFalse,
531
  SkipWriteBlockInfoRoot: cTrue,
 
532
  }
533
  if noZKEVMCounters {
534
  processBatchRequestV2.NoCounters = cTrue
@@ -642,6 +650,8 @@
642
  return nil, err
643
  }
644
 
 
 
645
  header := NewL2Header(&types.Header{
646
  Number: new(big.Int).SetUint64(lastL2Block.Number().Uint64() + 1),
647
  ParentHash: lastL2Block.Hash(),
@@ -655,8 +665,9 @@
655
  header.BlockInfoRoot = blockInfoRoot
656
  transactions := []*types.Transaction{&processedTx.Tx}
657
 
658
- receipt := GenerateReceipt(header.Number, processedTx, 0)
659
  receipts := []*types.Receipt{receipt}
 
660
 
661
  // Create l2Block to be able to calculate its hash
662
  st := trie.NewStackTrie(nil)
@@ -669,7 +680,7 @@
669
  txsL2Hash := []common.Hash{processedTx.TxHashL2_V2}
670
 
671
  // Store L2 block and its transaction
672
- if err := s.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, dbTx); err != nil {
673
  return nil, err
674
  }
675
 
@@ -1003,6 +1014,7 @@
1003
  TimestampLimit: uint64(time.Now().Unix()),
1004
  SkipFirstChangeL2Block: cTrue,
1005
  SkipWriteBlockInfoRoot: cTrue,
 
1006
  }
1007
 
1008
  log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From)
@@ -1034,7 +1046,6 @@
1034
  }
1035
  if processBatchResponseV2.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR {
1036
  err = executor.RomErr(processBatchResponseV2.ErrorRom)
1037
- s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2)
1038
  return false, false, gasUsed, nil, err
1039
  }
1040
 
 
117
  return ErrBatchAlreadyClosed
118
  }
119
 
120
+ forkID := s.GetForkIDByBatchNumber(batchNumber)
121
+
122
  for _, processedBlock := range processedBlocks {
123
  processedTxs := processedBlock.TransactionResponses
124
  // check existing txs vs parameter txs
 
169
  header.BlockInfoRoot = processedBlock.BlockInfoRoot
170
  transactions := []*types.Transaction{&processedTx.Tx}
171
 
172
+ receipt := GenerateReceipt(header.Number, processedTx, uint(i), forkID)
173
  if !CheckLogOrder(receipt.Logs) {
174
  return fmt.Errorf("error: logs received from executor are not in order")
175
  }
176
  receipts := []*types.Receipt{receipt}
177
+ imStateRoots := []common.Hash{processedTx.StateRoot}
178
 
179
  // Create l2Block to be able to calculate its hash
180
  st := trie.NewStackTrie(nil)
 
190
  txsL2Hash := []common.Hash{processedTx.TxHashL2_V2}
191
 
192
  // Store L2 block and its transaction
193
+ if err := s.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx); err != nil {
194
  return err
195
  }
196
  }
 
212
  return err
213
  }
214
 
215
+ forkID := s.GetForkIDByBatchNumber(batchNumber)
216
+
217
  gasLimit := l2Block.GasLimit
218
+ // We check/set the maximum value of gasLimit for batches <= to ETROG fork. For batches >= to ELDERBERRY fork we use always the value returned by the executor
219
+ if forkID <= FORKID_ETROG && gasLimit > MaxL2BlockGasLimit {
220
  gasLimit = MaxL2BlockGasLimit
221
  }
222
 
 
240
  storeTxsEGPData := make([]StoreTxEGPData, 0, numTxs)
241
  receipts := make([]*types.Receipt, 0, numTxs)
242
  txsL2Hash := make([]common.Hash, 0, numTxs)
243
+ imStateRoots := make([]common.Hash, 0, numTxs)
244
+ var receipt *types.Receipt
245
 
246
  for i, txResponse := range l2Block.TransactionResponses {
247
  // if the transaction has an intrinsic invalid tx error it means
 
252
  if executor.IsInvalidL2Block(executor.RomErrorCode(txResponse.RomError)) {
253
  continue
254
  }
 
255
  txResp := *txResponse
256
  transactions = append(transactions, &txResp.Tx)
257
  txsL2Hash = append(txsL2Hash, txResp.TxHashL2_V2)
 
258
  storeTxEGPData := StoreTxEGPData{EGPLog: nil, EffectivePercentage: uint8(txResponse.EffectivePercentage)}
259
  if txsEGPLog != nil {
260
  storeTxEGPData.EGPLog = txsEGPLog[i]
 
262
 
263
  storeTxsEGPData = append(storeTxsEGPData, storeTxEGPData)
264
 
265
+ receipt = GenerateReceipt(header.Number, txResponse, uint(i), forkID)
266
  receipts = append(receipts, receipt)
267
+ imStateRoots = append(imStateRoots, txResp.StateRoot)
268
  }
269
 
270
  // Create block to be able to calculate its hash
 
277
  }
278
 
279
  // Store L2 block and its transactions
280
+ if err := s.AddL2Block(ctx, batchNumber, block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx); err != nil {
281
  return err
282
  }
283
 
 
536
  TimestampLimit: uint64(time.Now().Unix()),
537
  SkipFirstChangeL2Block: cFalse,
538
  SkipWriteBlockInfoRoot: cTrue,
539
+ ExecutionMode: executor.ExecutionMode0,
540
  }
541
  if noZKEVMCounters {
542
  processBatchRequestV2.NoCounters = cTrue
 
650
  return nil, err
651
  }
652
 
653
+ forkID := s.GetForkIDByBatchNumber(batchNumber)
654
+
655
  header := NewL2Header(&types.Header{
656
  Number: new(big.Int).SetUint64(lastL2Block.Number().Uint64() + 1),
657
  ParentHash: lastL2Block.Hash(),
 
665
  header.BlockInfoRoot = blockInfoRoot
666
  transactions := []*types.Transaction{&processedTx.Tx}
667
 
668
+ receipt := GenerateReceipt(header.Number, processedTx, 0, forkID)
669
  receipts := []*types.Receipt{receipt}
670
+ imStateRoots := []common.Hash{processedTx.StateRoot}
671
 
672
  // Create l2Block to be able to calculate its hash
673
  st := trie.NewStackTrie(nil)
 
680
  txsL2Hash := []common.Hash{processedTx.TxHashL2_V2}
681
 
682
  // Store L2 block and its transaction
683
+ if err := s.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx); err != nil {
684
  return nil, err
685
  }
686
 
 
1014
  TimestampLimit: uint64(time.Now().Unix()),
1015
  SkipFirstChangeL2Block: cTrue,
1016
  SkipWriteBlockInfoRoot: cTrue,
1017
+ ExecutionMode: executor.ExecutionMode0,
1018
  }
1019
 
1020
  log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From)
 
1046
  }
1047
  if processBatchResponseV2.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR {
1048
  err = executor.RomErr(processBatchResponseV2.ErrorRom)
 
1049
  return false, false, gasUsed, nil, err
1050
  }
1051
 
{/home/stefan/go/src/Polygon/zkevm-node → .}/state/types.go RENAMED
@@ -100,6 +100,8 @@
100
  GasLeft uint64
101
  // GasUsed is the total gas used as result of execution or gas estimation
102
  GasUsed uint64
 
 
103
  // GasRefunded is the total gas refunded as result of execution
104
  GasRefunded uint64
105
  // RomError represents any error encountered during the execution
 
100
  GasLeft uint64
101
  // GasUsed is the total gas used as result of execution or gas estimation
102
  GasUsed uint64
103
+ // CumulativeGasUsed is the accumulated gas used (sum of tx GasUsed and CumulativeGasUsed of the previous tx in the L2 block)
104
+ CumulativeGasUsed uint64
105
  // GasRefunded is the total gas refunded as result of execution
106
  GasRefunded uint64
107
  // RomError represents any error encountered during the execution
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go RENAMED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package actions
2
+
3
+ import (
4
+ "context"
5
+ "errors"
6
+ "fmt"
7
+ "math/big"
8
+
9
+ "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
10
+ "github.com/0xPolygonHermez/zkevm-node/log"
11
+ "github.com/0xPolygonHermez/zkevm-node/state"
12
+ "github.com/jackc/pgx/v4"
13
+ )
14
+
15
+ // Implements PostClosedBatchChecker
16
+
17
+ type stateGetL2Block interface {
18
+ GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)
19
+ GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
20
+ }
21
+
22
+ type trustedRPCGetL2Block interface {
23
+ BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
24
+ }
25
+
26
+ // CheckL2BlockHash is a struct that implements a checker of L2Block hash
27
+ type CheckL2BlockHash struct {
28
+ state stateGetL2Block
29
+ trustedClient trustedRPCGetL2Block
30
+ lastL2BlockChecked uint64
31
+ // Is a modulus used to choose the l2block to check
32
+ modulusL2BlockToCheck uint64
33
+ }
34
+
35
+ // NewCheckL2BlockHash creates a new CheckL2BlockHash
36
+ func NewCheckL2BlockHash(state stateGetL2Block,
37
+ trustedClient trustedRPCGetL2Block,
38
+ initialL2BlockNumber uint64,
39
+ modulusBlockNumber uint64) *CheckL2BlockHash {
40
+ return &CheckL2BlockHash{
41
+ state: state,
42
+ trustedClient: trustedClient,
43
+ lastL2BlockChecked: initialL2BlockNumber,
44
+ modulusL2BlockToCheck: modulusBlockNumber,
45
+ }
46
+ }
47
+
48
+ // CheckL2Block checks the L2Block hash between the local and the trusted
49
+ func (p *CheckL2BlockHash) CheckL2Block(ctx context.Context, dbTx pgx.Tx) error {
50
+ lastLocalL2BlockNumber, err := p.state.GetLastL2BlockNumber(ctx, dbTx)
51
+ if errors.Is(err, state.ErrNotFound) || errors.Is(err, state.ErrStateNotSynchronized) {
52
+ log.Debugf("checkL2block:No L2Block in database. err: %s", err.Error())
53
+ return nil
54
+ }
55
+ if err != nil {
56
+ log.Errorf("checkL2block: Error getting last L2Block from the database. err: %s", err.Error())
57
+ return err
58
+ }
59
+ shouldCheck, l2BlockNumber := p.GetNextL2BlockToCheck(lastLocalL2BlockNumber, p.GetMinimumL2BlockToCheck())
60
+ if !shouldCheck {
61
+ return nil
62
+ }
63
+ err = p.iterationCheckL2Block(ctx, l2BlockNumber, dbTx)
64
+ if err != nil {
65
+ return err
66
+ }
67
+ return nil
68
+ }
69
+
70
+ // GetNextL2BlockToCheck returns true is need to check and the blocknumber
71
+ func (p *CheckL2BlockHash) GetNextL2BlockToCheck(lastLocalL2BlockNumber, minL2BlockNumberToCheck uint64) (bool, uint64) {
72
+ l2BlockNumber := max(minL2BlockNumberToCheck, lastLocalL2BlockNumber)
73
+ if l2BlockNumber > lastLocalL2BlockNumber {
74
+ log.Infof("checkL2block: skip check L2block (next to check: %d) currently LastL2BlockNumber: %d", minL2BlockNumberToCheck, lastLocalL2BlockNumber)
75
+ return false, 0
76
+ }
77
+ return true, l2BlockNumber
78
+ }
79
+
80
+ // GetMinimumL2BlockToCheck returns the minimum L2Block to check
81
+ func (p *CheckL2BlockHash) GetMinimumL2BlockToCheck() uint64 {
82
+ if p.modulusL2BlockToCheck == 0 {
83
+ return p.lastL2BlockChecked + 1
84
+ }
85
+ return ((p.lastL2BlockChecked / p.modulusL2BlockToCheck) + 1) * p.modulusL2BlockToCheck
86
+ }
87
+
88
+ // GetL2Blocks returns localL2Block and trustedL2Block
89
+ func (p *CheckL2BlockHash) GetL2Blocks(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, *types.Block, error) {
90
+ localL2Block, err := p.state.GetL2BlockByNumber(ctx, blockNumber, dbTx)
91
+ if err != nil {
92
+ log.Debugf("checkL2block: Error getting L2Block %d from the database. err: %s", blockNumber, err.Error())
93
+ return nil, nil, err
94
+ }
95
+ trustedL2Block, err := p.trustedClient.BlockByNumber(ctx, big.NewInt(int64(blockNumber)))
96
+ if err != nil {
97
+ log.Errorf("checkL2block: Error getting L2Block %d from the Trusted RPC. err:%s", blockNumber, err.Error())
98
+ return nil, nil, err
99
+ }
100
+ return localL2Block, trustedL2Block, nil
101
+ }
102
+
103
+ // CheckPostClosedBatch checks the last L2Block hash on close batch
104
+ func (p *CheckL2BlockHash) iterationCheckL2Block(ctx context.Context, l2BlockNumber uint64, dbTx pgx.Tx) error {
105
+ prefixLogs := fmt.Sprintf("checkL2block: L2BlockNumber: %d ", l2BlockNumber)
106
+ localL2Block, trustedL2Block, err := p.GetL2Blocks(ctx, l2BlockNumber, dbTx)
107
+ if errors.Is(err, state.ErrNotFound) || errors.Is(err, state.ErrStateNotSynchronized) {
108
+ log.Debugf("%s not found in the database", prefixLogs, l2BlockNumber)
109
+ return nil
110
+ }
111
+ if err != nil {
112
+ log.Errorf("%s Error getting from the database and trusted. err: %s", prefixLogs, err.Error())
113
+ return err
114
+ }
115
+ if localL2Block == nil || trustedL2Block == nil {
116
+ log.Errorf("%s localL2Block or trustedL2Block is nil", prefixLogs, l2BlockNumber)
117
+ return nil
118
+ }
119
+
120
+ if err := compareL2Blocks(prefixLogs, localL2Block, trustedL2Block); err != nil {
121
+ log.Errorf("%s Error comparing L2Blocks from the database and trusted. err: %s", prefixLogs, err.Error())
122
+ return err
123
+ }
124
+
125
+ log.Infof("%s checked L2Block in the database and the trusted batch are the same %s", prefixLogs, localL2Block.Hash().String())
126
+ // Compare the two blocks
127
+ p.lastL2BlockChecked = l2BlockNumber
128
+ return nil
129
+ }
130
+
131
+ func compareL2Blocks(prefixLogs string, localL2Block *state.L2Block, trustedL2Block *types.Block) error {
132
+ if localL2Block == nil || trustedL2Block == nil || trustedL2Block.Hash == nil {
133
+ return fmt.Errorf("%s localL2Block or trustedL2Block or trustedHash are nil", prefixLogs)
134
+ }
135
+ if localL2Block.Hash() != *trustedL2Block.Hash {
136
+ return fmt.Errorf("%s localL2Block.Hash %s and trustedL2Block.Hash %s are different", prefixLogs, localL2Block.Hash().String(), (*trustedL2Block.Hash).String())
137
+ }
138
+ return nil
139
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block_processor_decorator.go RENAMED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package actions
2
+
3
+ import (
4
+ "context"
5
+
6
+ "github.com/0xPolygonHermez/zkevm-node/etherman"
7
+ "github.com/jackc/pgx/v4"
8
+ )
9
+
10
+ // CheckL2BlockProcessorDecorator This class is just a decorator to call CheckL2Block
11
+ type CheckL2BlockProcessorDecorator struct {
12
+ L1EventProcessor
13
+ l2blockChecker *CheckL2BlockHash
14
+ }
15
+
16
+ // NewCheckL2BlockDecorator creates a new CheckL2BlockDecorator
17
+ func NewCheckL2BlockDecorator(l1EventProcessor L1EventProcessor, l2blockChecker *CheckL2BlockHash) *CheckL2BlockProcessorDecorator {
18
+ return &CheckL2BlockProcessorDecorator{
19
+ L1EventProcessor: l1EventProcessor,
20
+ l2blockChecker: l2blockChecker,
21
+ }
22
+ }
23
+
24
+ // Process wraps the real Process and after check the L2Blocks
25
+ func (p *CheckL2BlockProcessorDecorator) Process(ctx context.Context, order etherman.Order, l1Block *etherman.Block, dbTx pgx.Tx) error {
26
+ res := p.L1EventProcessor.Process(ctx, order, l1Block, dbTx)
27
+ if res != nil {
28
+ return res
29
+ }
30
+ if p.l2blockChecker == nil {
31
+ return nil
32
+ }
33
+ return p.l2blockChecker.CheckL2Block(ctx, dbTx)
34
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block_test.go RENAMED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package actions_test
2
+
3
+ import (
4
+ "context"
5
+ "math/big"
6
+ "testing"
7
+
8
+ rpctypes "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
9
+ "github.com/0xPolygonHermez/zkevm-node/state"
10
+ "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions"
11
+ mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks"
12
+ "github.com/ethereum/go-ethereum/common"
13
+ "github.com/ethereum/go-ethereum/core/types"
14
+ "github.com/stretchr/testify/assert"
15
+ "github.com/stretchr/testify/mock"
16
+ "github.com/stretchr/testify/require"
17
+ )
18
+
19
+ type CheckL2BlocksTestData struct {
20
+ sut *actions.CheckL2BlockHash
21
+ mockState *mock_syncinterfaces.StateFullInterface
22
+ zKEVMClient *mock_syncinterfaces.ZKEVMClientInterface
23
+ }
24
+
25
+ func TestCheckL2BlockHash_GetMinimumL2BlockToCheck(t *testing.T) {
26
+ // Create an instance of CheckL2BlockHash
27
+ values := []struct {
28
+ initial uint64
29
+ modulus uint64
30
+ expected uint64
31
+ }{
32
+ {0, 10, 10},
33
+ {1, 10, 10},
34
+ {9, 10, 10},
35
+ {10, 10, 20},
36
+ {0, 0, 1},
37
+ {1, 0, 2},
38
+ }
39
+ for _, data := range values {
40
+ // Call the GetNextL2BlockToCheck method
41
+ checkL2Block := actions.NewCheckL2BlockHash(nil, nil, data.initial, data.modulus)
42
+ nextL2Block := checkL2Block.GetMinimumL2BlockToCheck()
43
+
44
+ // Assert the expected result
45
+ assert.Equal(t, data.expected, nextL2Block)
46
+ }
47
+ }
48
+
49
+ func TestCheckL2BlockHashNotEnoughBlocksToCheck(t *testing.T) {
50
+ data := newCheckL2BlocksTestData(t, 0, 10)
51
+ // Call the CheckL2Block method
52
+ data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(uint64(0), nil)
53
+ err := data.sut.CheckL2Block(context.Background(), nil)
54
+ require.NoError(t, err)
55
+ }
56
+
57
+ func newCheckL2BlocksTestData(t *testing.T, initialL2Block, modulus uint64) CheckL2BlocksTestData {
58
+ res := CheckL2BlocksTestData{
59
+ mockState: mock_syncinterfaces.NewStateFullInterface(t),
60
+ zKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t),
61
+ }
62
+ res.sut = actions.NewCheckL2BlockHash(res.mockState, res.zKEVMClient, initialL2Block, modulus)
63
+ return res
64
+ }
65
+ func TestCheckL2BlockHash_GetNextL2BlockToCheck(t *testing.T) {
66
+ values := []struct {
67
+ lastLocalL2BlockNumber uint64
68
+ minL2BlockNumberToCheck uint64
69
+ expectedShouldCheck bool
70
+ expectedNextL2BlockNumber uint64
71
+ }{
72
+ {0, 10, false, 0},
73
+ {10, 10, true, 10},
74
+ {9, 10, false, 0},
75
+ {10, 10, true, 10},
76
+ {0, 0, true, 0},
77
+ {1, 0, true, 1},
78
+ }
79
+
80
+ for _, data := range values {
81
+ checkL2Block := actions.NewCheckL2BlockHash(nil, nil, 0, 0)
82
+ shouldCheck, nextL2Block := checkL2Block.GetNextL2BlockToCheck(data.lastLocalL2BlockNumber, data.minL2BlockNumberToCheck)
83
+
84
+ assert.Equal(t, data.expectedShouldCheck, shouldCheck, data)
85
+ assert.Equal(t, data.expectedNextL2BlockNumber, nextL2Block, data)
86
+ }
87
+ }
88
+
89
+ func TestCheckL2BlockHashMatch(t *testing.T) {
90
+ data := newCheckL2BlocksTestData(t, 1, 10)
91
+ lastL2Block := uint64(14)
92
+ lastL2BlockBigInt := big.NewInt(int64(lastL2Block))
93
+ gethHeader := types.Header{
94
+ Number: big.NewInt(int64(lastL2Block)),
95
+ }
96
+ stateBlock := state.NewL2Block(state.NewL2Header(&gethHeader), nil, nil, nil, nil)
97
+
98
+ data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil)
99
+ data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil)
100
+ l2blockHash := stateBlock.Hash()
101
+ rpcL2Block := rpctypes.Block{
102
+ Hash: &l2blockHash,
103
+ Number: rpctypes.ArgUint64(lastL2Block),
104
+ }
105
+
106
+ data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(&rpcL2Block, nil)
107
+ err := data.sut.CheckL2Block(context.Background(), nil)
108
+ require.NoError(t, err)
109
+ }
110
+
111
+ func TestCheckL2BlockHashMissmatch(t *testing.T) {
112
+ data := newCheckL2BlocksTestData(t, 1, 10)
113
+ lastL2Block := uint64(14)
114
+ lastL2BlockBigInt := big.NewInt(int64(lastL2Block))
115
+ gethHeader := types.Header{
116
+ Number: big.NewInt(int64(lastL2Block)),
117
+ }
118
+ stateBlock := state.NewL2Block(state.NewL2Header(&gethHeader), nil, nil, nil, nil)
119
+
120
+ data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil)
121
+ data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil)
122
+ l2blockHash := common.HexToHash("0x1234")
123
+ rpcL2Block := rpctypes.Block{
124
+ Hash: &l2blockHash,
125
+ Number: rpctypes.ArgUint64(lastL2Block),
126
+ }
127
+
128
+ data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(&rpcL2Block, nil)
129
+ err := data.sut.CheckL2Block(context.Background(), nil)
130
+ require.Error(t, err)
131
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches.go RENAMED
@@ -381,6 +381,11 @@
381
  log.Warnf(errMsg)
382
  reorgReasons.WriteString(errMsg)
383
  }
 
 
 
 
 
384
 
385
  if reorgReasons.Len() > 0 {
386
  reason := reorgReasons.String()
 
381
  log.Warnf(errMsg)
382
  reorgReasons.WriteString(errMsg)
383
  }
384
+ if tBatch.WIP {
385
+ errMsg := batchNumStr + "Trusted batch is WIP\n"
386
+ log.Warnf(errMsg)
387
+ reorgReasons.WriteString(errMsg)
388
+ }
389
 
390
  if reorgReasons.Len() > 0 {
391
  reason := reorgReasons.String()
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/forksids.go RENAMED
@@ -12,6 +12,8 @@
12
  ForkIDEtrog = ForkIdType(7) //nolint:gomnd
13
  // ForkIDElderberry is the forkId for Elderberry
14
  ForkIDElderberry = ForkIdType(8) //nolint:gomnd
 
 
15
  )
16
 
17
  var (
@@ -20,7 +22,7 @@
20
  ForksIdAll = []ForkIdType{WildcardForkId}
21
 
22
  // ForksIdOnlyElderberry support only elderberry forkId
23
- ForksIdOnlyElderberry = []ForkIdType{ForkIDElderberry}
24
 
25
  // ForksIdOnlyEtrog support only etrog forkId
26
  ForksIdOnlyEtrog = []ForkIdType{ForkIDEtrog}
 
12
  ForkIDEtrog = ForkIdType(7) //nolint:gomnd
13
  // ForkIDElderberry is the forkId for Elderberry
14
  ForkIDElderberry = ForkIdType(8) //nolint:gomnd
15
+ // ForkID9 is the forkId for 9
16
+ ForkID9 = ForkIdType(9) //nolint:gomnd
17
  )
18
 
19
  var (
 
22
  ForksIdAll = []ForkIdType{WildcardForkId}
23
 
24
  // ForksIdOnlyElderberry support only elderberry forkId
25
+ ForksIdOnlyElderberry = []ForkIdType{ForkIDElderberry, ForkID9}
26
 
27
  // ForksIdOnlyEtrog support only etrog forkId
28
  ForksIdOnlyEtrog = []ForkIdType{ForkIDEtrog}
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forkid.go RENAMED
@@ -5,6 +5,7 @@
5
  "errors"
6
  "fmt"
7
  "math"
 
8
 
9
  "github.com/0xPolygonHermez/zkevm-node/etherman"
10
  "github.com/0xPolygonHermez/zkevm-node/log"
@@ -18,6 +19,7 @@
18
  GetForkIDs(ctx context.Context, dbTx pgx.Tx) ([]state.ForkIDInterval, error)
19
  AddForkIDInterval(ctx context.Context, newForkID state.ForkIDInterval, dbTx pgx.Tx) error
20
  ResetForkID(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
 
21
  }
22
 
23
  type syncProcessorForkIdInterface interface {
@@ -44,9 +46,86 @@
44
 
45
  // Process process event
46
  func (p *ProcessorForkId) Process(ctx context.Context, order etherman.Order, l1Block *etherman.Block, dbTx pgx.Tx) error {
 
 
 
 
 
 
47
  return p.processForkID(ctx, l1Block.ForkIDs[order.Pos], l1Block.BlockNumber, dbTx)
48
  }
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  func (s *ProcessorForkId) processForkID(ctx context.Context, forkID etherman.ForkID, blockNumber uint64, dbTx pgx.Tx) error {
51
  fID := state.ForkIDInterval{
52
  FromBatchNumber: forkID.BatchNumber + 1,
@@ -55,74 +134,81 @@
55
  Version: forkID.Version,
56
  BlockNumber: blockNumber,
57
  }
58
-
59
  // If forkID affects to a batch from the past. State must be reseted.
60
- log.Debugf("ForkID: %d, synchronization must use the new forkID since batch: %d", forkID.ForkID, forkID.BatchNumber+1)
61
  fIds, err := s.state.GetForkIDs(ctx, dbTx)
62
  if err != nil {
63
- log.Error("error getting ForkIDTrustedReorg. Error: ", err)
64
- rollbackErr := dbTx.Rollback(ctx)
65
- if rollbackErr != nil {
66
- log.Errorf("error rolling back state get forkID trusted state. BlockNumber: %d, rollbackErr: %s, error : %v", blockNumber, rollbackErr.Error(), err)
67
- return rollbackErr
68
- }
69
  return err
70
  }
71
- if len(fIds) != 0 && fIds[len(fIds)-1].ForkId == fID.ForkId { // If the forkID reset was already done
72
- return nil
 
 
 
 
 
 
 
 
 
 
 
73
  }
 
74
  //If the forkID.batchnumber is a future batch
75
  latestBatchNumber, err := s.state.GetLastBatchNumber(ctx, dbTx)
76
  if err != nil && !errors.Is(err, state.ErrStateNotSynchronized) {
77
- log.Error("error getting last batch number. Error: ", err)
78
- rollbackErr := dbTx.Rollback(ctx)
79
- if rollbackErr != nil {
80
- log.Errorf("error rolling back state. BlockNumber: %d, rollbackErr: %s, error : %v", blockNumber, rollbackErr.Error(), err)
81
- return rollbackErr
82
- }
83
  return err
84
  }
85
- // Add new forkID to the state
86
  err = s.state.AddForkIDInterval(ctx, fID, dbTx)
87
  if err != nil {
88
- log.Error("error adding new forkID interval to the state. Error: ", err)
89
- rollbackErr := dbTx.Rollback(ctx)
90
- if rollbackErr != nil {
91
- log.Errorf("error rolling back state to store block. BlockNumber: %d, rollbackErr: %s, error : %v", blockNumber, rollbackErr.Error(), err)
92
- return rollbackErr
93
- }
94
  return err
95
  }
96
- if latestBatchNumber <= forkID.BatchNumber || s.sync.IsTrustedSequencer() { //If the forkID will start in a future batch or isTrustedSequencer
97
- log.Infof("Just adding forkID. Skipping reset forkID. ForkID: %+v.", fID)
 
 
 
 
 
98
  return nil
99
  }
100
 
101
- log.Info("ForkID received in the permissionless node that affects to a batch from the past")
102
  //Reset DB only if permissionless node
103
- log.Debugf("ForkID: %d, Reverting synchronization to batch: %d", forkID.ForkID, forkID.BatchNumber+1)
104
  err = s.state.ResetForkID(ctx, forkID.BatchNumber+1, dbTx)
105
  if err != nil {
106
- log.Error("error resetting the state. Error: ", err)
107
- rollbackErr := dbTx.Rollback(ctx)
108
- if rollbackErr != nil {
109
- log.Errorf("error rolling back state to store block. BlockNumber: %d, rollbackErr: %s, error : %v", blockNumber, rollbackErr.Error(), err)
110
- return rollbackErr
111
- }
112
  return err
113
  }
114
 
115
  // Commit because it returns an error to force the resync
116
- err = dbTx.Commit(ctx)
 
 
 
 
 
 
 
 
 
 
 
117
  if err != nil {
118
- log.Error("error committing the resetted state. Error: ", err)
119
  rollbackErr := dbTx.Rollback(ctx)
120
  if rollbackErr != nil {
121
- log.Errorf("error rolling back state to store block. BlockNumber: %d, rollbackErr: %s, error : %v", blockNumber, rollbackErr.Error(), err)
122
  return rollbackErr
123
  }
124
  return err
125
  }
126
-
127
- return fmt.Errorf("new ForkID detected, reseting synchronizarion")
128
  }
 
5
  "errors"
6
  "fmt"
7
  "math"
8
+ "sort"
9
 
10
  "github.com/0xPolygonHermez/zkevm-node/etherman"
11
  "github.com/0xPolygonHermez/zkevm-node/log"
 
19
  GetForkIDs(ctx context.Context, dbTx pgx.Tx) ([]state.ForkIDInterval, error)
20
  AddForkIDInterval(ctx context.Context, newForkID state.ForkIDInterval, dbTx pgx.Tx) error
21
  ResetForkID(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
22
+ UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error
23
  }
24
 
25
  type syncProcessorForkIdInterface interface {
 
46
 
47
  // Process process event
48
  func (p *ProcessorForkId) Process(ctx context.Context, order etherman.Order, l1Block *etherman.Block, dbTx pgx.Tx) error {
49
+ if l1Block == nil {
50
+ return errors.New("nil l1Block")
51
+ }
52
+ if len(l1Block.ForkIDs) <= order.Pos {
53
+ return fmt.Errorf("ForkIDsOrder index out of range. BlockNumber: %d, ForkIDsOrder index: %d", l1Block.BlockNumber, order.Pos)
54
+ }
55
  return p.processForkID(ctx, l1Block.ForkIDs[order.Pos], l1Block.BlockNumber, dbTx)
56
  }
57
 
58
+ func getForkdFromSlice(fIds []state.ForkIDInterval, forkId uint64) (bool, state.ForkIDInterval) {
59
+ if len(fIds) == 0 {
60
+ return false, state.ForkIDInterval{}
61
+ }
62
+ for _, f := range fIds {
63
+ if f.ForkId == forkId {
64
+ return true, f
65
+ }
66
+ }
67
+ return false, state.ForkIDInterval{}
68
+ }
69
+
70
+ func isForksSameFromBatchNumber(f1, f2 state.ForkIDInterval) bool {
71
+ return f1.ForkId == f2.ForkId && f1.FromBatchNumber == f2.FromBatchNumber
72
+ }
73
+
74
+ func isIncommingForkIdGreatestThanLastOne(incommingForkID state.ForkIDInterval, fIds []state.ForkIDInterval) bool {
75
+ if len(fIds) == 0 {
76
+ return true
77
+ }
78
+ last := lastForkID(fIds)
79
+ // Must be greater than the last one
80
+ return incommingForkID.ForkId > last
81
+ }
82
+
83
+ func lastForkID(fIds []state.ForkIDInterval) uint64 {
84
+ if len(fIds) == 0 {
85
+ return 0
86
+ }
87
+ sort.Slice(fIds, func(i, j int) bool {
88
+ return fIds[i].ForkId > fIds[j].ForkId
89
+ })
90
+ return fIds[0].ForkId
91
+ }
92
+
93
+ // return true if have been update or false if it's a new one
94
+ func (s *ProcessorForkId) updateForkIDIfNeeded(ctx context.Context, forkIDincomming state.ForkIDInterval, forkIDsInState []state.ForkIDInterval, dbTx pgx.Tx) (bool, error) {
95
+ found, dbForkID := getForkdFromSlice(forkIDsInState, forkIDincomming.ForkId)
96
+ if !found {
97
+ // Is a new forkid
98
+ return false, nil
99
+ }
100
+ if isForksSameFromBatchNumber(forkIDincomming, dbForkID) {
101
+ if forkIDincomming.BlockNumber != dbForkID.BlockNumber {
102
+ isLastForkId := lastForkID(forkIDsInState) == forkIDincomming.ForkId
103
+ log.Infof("ForkID: %d, received again: same fork_id but different blockNumber old: %d, new: %d", forkIDincomming.ForkId, dbForkID.BlockNumber, forkIDincomming.BlockNumber)
104
+ if isLastForkId {
105
+ log.Warnf("ForkID: %d is the last one in the state. Updating BlockNumber from %d to %d", forkIDincomming.ForkId, dbForkID.BlockNumber, forkIDincomming.BlockNumber)
106
+ err := s.state.UpdateForkIDBlockNumber(ctx, forkIDincomming.ForkId, forkIDincomming.BlockNumber, true, dbTx)
107
+ if err != nil {
108
+ log.Errorf("error updating forkID: %d blocknumber. Error: %v", forkIDincomming.ForkId, err)
109
+ return true, err
110
+ }
111
+ return true, nil
112
+ }
113
+ err := fmt.Errorf("ForkID: %d, already in the state but with different blockNumber and is not last ForkID, so can't update BlockNumber. DB ForkID: %+v. New ForkID: %+v", forkIDincomming.ForkId, dbForkID, forkIDincomming)
114
+ log.Error(err.Error())
115
+ return true, err
116
+ }
117
+ log.Infof("ForkID: %d, already in the state. Skipping . ForkID: %+v.", forkIDincomming.ForkId, forkIDincomming)
118
+ return true, nil
119
+ }
120
+ err := fmt.Errorf("ForkID: %d, already in the state but with different starting BatchNumber. DB ForkID: %+v. New ForkID: %+v", forkIDincomming.ForkId, dbForkID, forkIDincomming)
121
+ log.Error(err.Error())
122
+ return true, err
123
+ }
124
+
125
+ func isForkIdAffectingOnlyFuturesBatches(fID state.ForkIDInterval, latestBatchNumber uint64) bool {
126
+ return latestBatchNumber < fID.FromBatchNumber
127
+ }
128
+
129
  func (s *ProcessorForkId) processForkID(ctx context.Context, forkID etherman.ForkID, blockNumber uint64, dbTx pgx.Tx) error {
130
  fID := state.ForkIDInterval{
131
  FromBatchNumber: forkID.BatchNumber + 1,
 
134
  Version: forkID.Version,
135
  BlockNumber: blockNumber,
136
  }
137
+ debugPrefix := fmt.Sprintf("ForkID: %d, BlockNumber:%d, ", forkID.ForkID, blockNumber)
138
  // If forkID affects to a batch from the past. State must be reseted.
139
+ log.Debugf("%s synchronization must use the new forkID since batch: %d", debugPrefix, forkID.BatchNumber+1)
140
  fIds, err := s.state.GetForkIDs(ctx, dbTx)
141
  if err != nil {
142
+ log.Errorf("error getting forkIDs. Error: %v", err)
 
 
 
 
 
143
  return err
144
  }
145
+ isUpdate, err := s.updateForkIDIfNeeded(ctx, fID, fIds, dbTx)
146
+ if err != nil {
147
+ log.Errorf("%s error updating forkID . Error: %v", debugPrefix, err)
148
+ return err
149
+ }
150
+ if isUpdate {
151
+ return nil // The calling function is doing the commit
152
+ }
153
+
154
+ if !isIncommingForkIdGreatestThanLastOne(fID, fIds) {
155
+ err = fmt.Errorf("%s received don't fit sequence, last forkid:%d ", debugPrefix, lastForkID(fIds))
156
+ log.Error(err.Error())
157
+ return err
158
  }
159
+
160
  //If the forkID.batchnumber is a future batch
161
  latestBatchNumber, err := s.state.GetLastBatchNumber(ctx, dbTx)
162
  if err != nil && !errors.Is(err, state.ErrStateNotSynchronized) {
163
+ log.Errorf("%s error getting last batch number. Error: %v", debugPrefix, err)
 
 
 
 
 
164
  return err
165
  }
166
+ // Add new forkID to the state. This function take care of chaning previous ForkID ToBatchNumber
167
  err = s.state.AddForkIDInterval(ctx, fID, dbTx)
168
  if err != nil {
169
+ log.Errorf("%s error adding new forkID interval to state. Error: %v", debugPrefix, err)
 
 
 
 
 
170
  return err
171
  }
172
+ if isForkIdAffectingOnlyFuturesBatches(fID, latestBatchNumber) {
173
+ log.Infof("%s Just adding forkID for future batches. Skipping reset forkID. ForkID: %+v.", debugPrefix, fID)
174
+ return nil
175
+ }
176
+
177
+ if s.sync.IsTrustedSequencer() { //If the forkID will start in a future batch and IsTrustedSequencer
178
+ log.Warnf("%s received forkid that affects to a batch from the past %d, last Batch: %d. Is a trusted Node, so we accept it with no modifications", debugPrefix, fID.FromBatchNumber, latestBatchNumber)
179
  return nil
180
  }
181
 
182
+ log.Warnf("%s received in the permissionless node that affects to a batch from the past %d, last Batch: %d. Reverting state", debugPrefix, fID.FromBatchNumber, latestBatchNumber)
183
  //Reset DB only if permissionless node
184
+ log.Debugf("%s Reverting synchronization to batch: %d", debugPrefix, forkID.BatchNumber+1)
185
  err = s.state.ResetForkID(ctx, forkID.BatchNumber+1, dbTx)
186
  if err != nil {
187
+ log.Errorf("%s error resetting forkID. Error: %v", debugPrefix, err)
 
 
 
 
 
188
  return err
189
  }
190
 
191
  // Commit because it returns an error to force the resync
192
+ err = s.commit(ctx, debugPrefix, dbTx)
193
+ if err != nil {
194
+ log.Errorf("%s error committing forkId. Error: %v", debugPrefix, err)
195
+ return err
196
+ }
197
+ log.Infof("%s new ForkID detected, committed reverting state", debugPrefix)
198
+
199
+ return fmt.Errorf("new ForkID detected, reseting synchronizarion")
200
+ }
201
+
202
+ func (s *ProcessorForkId) commit(ctx context.Context, debugPrefix string, dbTx pgx.Tx) error {
203
+ err := dbTx.Commit(ctx)
204
  if err != nil {
205
+ log.Errorf("%s error committing forkId. Error: %s", debugPrefix, err.Error())
206
  rollbackErr := dbTx.Rollback(ctx)
207
  if rollbackErr != nil {
208
+ log.Errorf("%s error rolling back state to store block. rollbackErr: %s, error : %v", debugPrefix, rollbackErr.Error(), err)
209
  return rollbackErr
210
  }
211
  return err
212
  }
213
+ return nil
 
214
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forkid_test.go RENAMED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package incaberry_test
2
+
3
+ import (
4
+ "context"
5
+ "testing"
6
+
7
+ "github.com/0xPolygonHermez/zkevm-node/etherman"
8
+ "github.com/0xPolygonHermez/zkevm-node/state"
9
+ "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions/incaberry"
10
+ mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks"
11
+ syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks"
12
+ "github.com/stretchr/testify/mock"
13
+ "github.com/stretchr/testify/require"
14
+ )
15
+
16
+ type mockForkdIdTest struct {
17
+ mockState *mock_syncinterfaces.StateFullInterface
18
+ mockSync *mock_syncinterfaces.SynchronizerIsTrustedSequencer
19
+ mockDbTx *syncMocks.DbTxMock
20
+ }
21
+
22
+ func newMockForkdIdTest(t *testing.T) *mockForkdIdTest {
23
+ mockState := mock_syncinterfaces.NewStateFullInterface(t)
24
+ mockSync := mock_syncinterfaces.NewSynchronizerIsTrustedSequencer(t)
25
+ mockDbTx := syncMocks.NewDbTxMock(t)
26
+ return &mockForkdIdTest{mockState, mockSync, mockDbTx}
27
+ }
28
+
29
+ func newL1Block(blockNumber uint64, forkId uint64, fromBatchNumber uint64, version string) *etherman.Block {
30
+ return &etherman.Block{
31
+ SequencedBatches: [][]etherman.SequencedBatch{},
32
+ BlockNumber: blockNumber,
33
+ ForkIDs: []etherman.ForkID{{ForkID: forkId, BatchNumber: fromBatchNumber, Version: version}},
34
+ }
35
+ }
36
+
37
+ func TestReceiveExistingForkIdAnotherFromBatchNumber(t *testing.T) {
38
+ mocks := newMockForkdIdTest(t)
39
+ sut := incaberry.NewProcessorForkId(mocks.mockState, mocks.mockSync)
40
+ forkIdsOnState := []state.ForkIDInterval{
41
+ {FromBatchNumber: 1, ToBatchNumber: 100, ForkId: 6, Version: "1.0.0", BlockNumber: 123},
42
+ {FromBatchNumber: 101, ToBatchNumber: 200, ForkId: 7, Version: "1.0.0", BlockNumber: 123},
43
+ }
44
+ mocks.mockState.EXPECT().GetForkIDs(mock.Anything, mock.Anything).Return(forkIdsOnState, nil)
45
+ err := sut.Process(context.Background(), etherman.Order{Pos: 0}, newL1Block(123, 6, 500, "1.0.0"), mocks.mockDbTx)
46
+ require.Error(t, err)
47
+ }
48
+
49
+ func TestReceiveExistsForkIdSameBatchNumberSameBlockNumber(t *testing.T) {
50
+ mocks := newMockForkdIdTest(t)
51
+ sut := incaberry.NewProcessorForkId(mocks.mockState, mocks.mockSync)
52
+ forkIdsOnState := []state.ForkIDInterval{
53
+ {FromBatchNumber: 1, ToBatchNumber: 100, ForkId: 6, Version: "1.0.0", BlockNumber: 123},
54
+ {FromBatchNumber: 101, ToBatchNumber: 200, ForkId: 7, Version: "1.0.0", BlockNumber: 123},
55
+ }
56
+ mocks.mockState.EXPECT().GetForkIDs(mock.Anything, mock.Anything).Return(forkIdsOnState, nil)
57
+
58
+ err := sut.Process(context.Background(), etherman.Order{Pos: 0}, newL1Block(123, 6, 0, "1.0.0"), mocks.mockDbTx)
59
+ require.NoError(t, err)
60
+ }
61
+
62
+ func TestReceiveExistsForkIdSameBatchNumberAnotherBlockNumberAndNotLastForkId(t *testing.T) {
63
+ mocks := newMockForkdIdTest(t)
64
+ sut := incaberry.NewProcessorForkId(mocks.mockState, mocks.mockSync)
65
+ forkIdsOnState := []state.ForkIDInterval{
66
+ {FromBatchNumber: 1, ToBatchNumber: 100, ForkId: 6, Version: "1.0.0", BlockNumber: 123},
67
+ {FromBatchNumber: 101, ToBatchNumber: 200, ForkId: 7, Version: "1.0.0", BlockNumber: 123},
68
+ }
69
+ mocks.mockState.EXPECT().GetForkIDs(mock.Anything, mock.Anything).Return(forkIdsOnState, nil)
70
+ //mocks.mockDbTx.EXPECT().Rollback(mock.Anything).Return(nil)
71
+ err := sut.Process(context.Background(), etherman.Order{Pos: 0}, newL1Block(456, 6, 0, "1.0.0"), mocks.mockDbTx)
72
+ require.Error(t, err)
73
+ }
74
+
75
+ func TestReceiveAForkIdWithIdPreviousToCurrentOnState(t *testing.T) {
76
+ mocks := newMockForkdIdTest(t)
77
+ sut := incaberry.NewProcessorForkId(mocks.mockState, mocks.mockSync)
78
+ forkIdsOnState := []state.ForkIDInterval{
79
+ {FromBatchNumber: 100, ToBatchNumber: 200, ForkId: 6, Version: "1.0.0", BlockNumber: 123},
80
+ {FromBatchNumber: 201, ToBatchNumber: 300, ForkId: 7, Version: "1.0.0", BlockNumber: 123},
81
+ }
82
+ mocks.mockState.EXPECT().GetForkIDs(mock.Anything, mock.Anything).Return(forkIdsOnState, nil)
83
+ err := sut.Process(context.Background(), etherman.Order{Pos: 0}, newL1Block(456, 5, 0, "1.0.0"), mocks.mockDbTx)
84
+ require.Error(t, err)
85
+ }
86
+
87
+ func TestReceiveExistsForkIdSameBatchNumberAnotherBlockNumberAndLastForkId(t *testing.T) {
88
+ mocks := newMockForkdIdTest(t)
89
+ sut := incaberry.NewProcessorForkId(mocks.mockState, mocks.mockSync)
90
+ forkIdsOnState := []state.ForkIDInterval{
91
+ {FromBatchNumber: 1, ToBatchNumber: 100, ForkId: 6, Version: "1.0.0", BlockNumber: 123},
92
+ {FromBatchNumber: 101, ToBatchNumber: 200, ForkId: 7, Version: "1.0.0", BlockNumber: 123},
93
+ }
94
+ mocks.mockState.EXPECT().GetForkIDs(mock.Anything, mock.Anything).Return(forkIdsOnState, nil)
95
+ mocks.mockState.EXPECT().UpdateForkIDBlockNumber(mock.Anything, uint64(7), uint64(456), true, mock.Anything).Return(nil)
96
+ //mocks.mockDbTx.EXPECT().Commit(mock.Anything).Return(nil)
97
+ err := sut.Process(context.Background(), etherman.Order{Pos: 0}, newL1Block(456, 7, 100, "1.0.0"), mocks.mockDbTx)
98
+ require.NoError(t, err)
99
+ }
100
+
101
+ func TestReceiveNewForkIdAffectFutureBatch(t *testing.T) {
102
+ mocks := newMockForkdIdTest(t)
103
+ sut := incaberry.NewProcessorForkId(mocks.mockState, mocks.mockSync)
104
+ forkIdsOnState := []state.ForkIDInterval{
105
+ {FromBatchNumber: 1, ToBatchNumber: 100, ForkId: 6, Version: "1.0.0", BlockNumber: 123},
106
+ {FromBatchNumber: 101, ToBatchNumber: 200, ForkId: 7, Version: "1.0.0", BlockNumber: 123},
107
+ }
108
+ mocks.mockState.EXPECT().GetForkIDs(mock.Anything, mock.Anything).Return(forkIdsOnState, nil)
109
+ mocks.mockState.EXPECT().GetLastBatchNumber(mock.Anything, mock.Anything).Return(uint64(101), nil)
110
+ mocks.mockState.EXPECT().AddForkIDInterval(mock.Anything, state.ForkIDInterval{FromBatchNumber: 102, ToBatchNumber: ^uint64(0), ForkId: 8, Version: "2.0.0", BlockNumber: 456}, mock.Anything).Return(nil)
111
+ //mocks.mockDbTx.EXPECT().Commit(mock.Anything).Return(nil)
112
+ err := sut.Process(context.Background(), etherman.Order{Pos: 0}, newL1Block(456, 8, 101, "2.0.0"), mocks.mockDbTx)
113
+ require.NoError(t, err)
114
+ }
115
+
116
+ func TestReceiveNewForkIdAffectPastBatchTrustedNode(t *testing.T) {
117
+ mocks := newMockForkdIdTest(t)
118
+ sut := incaberry.NewProcessorForkId(mocks.mockState, mocks.mockSync)
119
+ forkIdsOnState := []state.ForkIDInterval{
120
+ {FromBatchNumber: 1, ToBatchNumber: 100, ForkId: 6, Version: "1.0.0", BlockNumber: 123},
121
+ {FromBatchNumber: 101, ToBatchNumber: 200, ForkId: 7, Version: "1.0.0", BlockNumber: 123},
122
+ }
123
+ mocks.mockState.EXPECT().GetForkIDs(mock.Anything, mock.Anything).Return(forkIdsOnState, nil)
124
+ mocks.mockState.EXPECT().GetLastBatchNumber(mock.Anything, mock.Anything).Return(uint64(101), nil)
125
+ mocks.mockState.EXPECT().AddForkIDInterval(mock.Anything, state.ForkIDInterval{FromBatchNumber: 101, ToBatchNumber: ^uint64(0), ForkId: 8, Version: "2.0.0", BlockNumber: 456}, mock.Anything).Return(nil)
126
+ mocks.mockSync.EXPECT().IsTrustedSequencer().Return(true)
127
+ err := sut.Process(context.Background(), etherman.Order{Pos: 0}, newL1Block(456, 8, 100, "2.0.0"), mocks.mockDbTx)
128
+ require.NoError(t, err)
129
+ }
130
+
131
+ func TestReceiveNewForkIdAffectPastBatchPermissionlessNode(t *testing.T) {
132
+ mocks := newMockForkdIdTest(t)
133
+ sut := incaberry.NewProcessorForkId(mocks.mockState, mocks.mockSync)
134
+ forkIdsOnState := []state.ForkIDInterval{
135
+ {FromBatchNumber: 1, ToBatchNumber: 100, ForkId: 6, Version: "1.0.0", BlockNumber: 123},
136
+ {FromBatchNumber: 101, ToBatchNumber: 200, ForkId: 7, Version: "1.0.0", BlockNumber: 123},
137
+ }
138
+ mocks.mockState.EXPECT().GetForkIDs(mock.Anything, mock.Anything).Return(forkIdsOnState, nil)
139
+ mocks.mockState.EXPECT().GetLastBatchNumber(mock.Anything, mock.Anything).Return(uint64(101), nil)
140
+ mocks.mockState.EXPECT().AddForkIDInterval(mock.Anything, state.ForkIDInterval{FromBatchNumber: 101, ToBatchNumber: ^uint64(0), ForkId: 8, Version: "2.0.0", BlockNumber: 456}, mock.Anything).Return(nil)
141
+ mocks.mockSync.EXPECT().IsTrustedSequencer().Return(false)
142
+ mocks.mockState.EXPECT().ResetForkID(mock.Anything, uint64(101), mock.Anything).Return(nil)
143
+ mocks.mockDbTx.EXPECT().Commit(mock.Anything).Return(nil)
144
+ err := sut.Process(context.Background(), etherman.Order{Pos: 0}, newL1Block(456, 8, 100, "2.0.0"), mocks.mockDbTx)
145
+ require.Error(t, err)
146
+ require.Equal(t, "new ForkID detected, reseting synchronizarion", err.Error())
147
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/state.go RENAMED
@@ -70,4 +70,7 @@
70
  GetExitRootByGlobalExitRoot(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*state.GlobalExitRoot, error)
71
  GetForkIDInMemory(forkId uint64) *state.ForkIDInterval
72
  GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)
 
 
 
73
  }
 
70
  GetExitRootByGlobalExitRoot(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*state.GlobalExitRoot, error)
71
  GetForkIDInMemory(forkId uint64) *state.ForkIDInterval
72
  GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)
73
+ UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error
74
+ GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
75
+ GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)
76
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/zkevm_rpc.go RENAMED
@@ -19,7 +19,12 @@
19
  ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error)
20
  }
21
 
 
 
 
 
22
  type ZKEVMClientInterface interface {
23
  ZKEVMClientTrustedBatchesGetter
24
  ZKEVMClientGlobalExitRootGetter
 
25
  }
 
19
  ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error)
20
  }
21
 
22
+ type ZKEVMClientGetL2BlockByNumber interface {
23
+ BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
24
+ }
25
+
26
  type ZKEVMClientInterface interface {
27
  ZKEVMClientTrustedBatchesGetter
28
  ZKEVMClientGlobalExitRootGetter
29
+ ZKEVMClientGetL2BlockByNumber
30
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/config.go RENAMED
@@ -14,6 +14,12 @@
14
  // TrustedSequencerURL is the rpc url to connect and sync the trusted state
15
  TrustedSequencerURL string `mapstructure:"TrustedSequencerURL"`
16
 
 
 
 
 
 
 
17
  // L1SynchronizationMode define how to synchronize with L1:
18
  // - parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data
19
  // - sequential: Request data to L1 and execute
 
14
  // TrustedSequencerURL is the rpc url to connect and sync the trusted state
15
  TrustedSequencerURL string `mapstructure:"TrustedSequencerURL"`
16
 
17
+ // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless)
18
+ L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"`
19
+ // L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check
20
+ // a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)
21
+ L1SyncCheckL2BlockNumberhModulus uint64 `mapstructure:"L1SyncCheckL2BlockNumberhModulus"`
22
+
23
  // L1SynchronizationMode define how to synchronize with L1:
24
  // - parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data
25
  // - sequential: Request data to L1 and execute
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/default_l1processors.go RENAMED
@@ -8,19 +9,19 @@
8
  "github.com/0xPolygonHermez/zkevm-node/synchronizer/common"
9
  )
10
 
11
- func defaultsL1EventProcessors(sync *ClientSynchronizer) *processor_manager.L1EventProcessors {
12
  p := processor_manager.NewL1EventProcessorsBuilder()
13
  p.Register(incaberry.NewProcessorL1GlobalExitRoot(sync.state))
14
- p.Register(incaberry.NewProcessorL1SequenceBatches(sync.state, sync.etherMan, sync.pool, sync.eventLog, sync))
15
- p.Register(incaberry.NewProcessL1ForcedBatches(sync.state))
16
- p.Register(incaberry.NewProcessL1SequenceForcedBatches(sync.state, sync))
17
  p.Register(incaberry.NewProcessorForkId(sync.state, sync))
18
  p.Register(etrog.NewProcessorL1InfoTreeUpdate(sync.state))
19
  sequenceBatchesProcessor := etrog.NewProcessorL1SequenceBatches(sync.state, sync, common.DefaultTimeProvider{}, sync.halter)
20
- p.Register(sequenceBatchesProcessor)
21
  p.Register(incaberry.NewProcessorL1VerifyBatch(sync.state))
22
  p.Register(etrog.NewProcessorL1UpdateEtrogSequence(sync.state, sync, common.DefaultTimeProvider{}))
23
- p.Register(elderberry.NewProcessorL1SequenceBatchesElderberry(sequenceBatchesProcessor, sync.state))
24
  // intialSequence is process in ETROG by the same class, this is just a wrapper to pass directly to ETROG
25
  p.Register(elderberry.NewProcessorL1InitialSequenceBatchesElderberry(sequenceBatchesProcessor))
26
  return p.Build()
 
9
  "github.com/0xPolygonHermez/zkevm-node/synchronizer/common"
10
  )
11
 
12
+ func defaultsL1EventProcessors(sync *ClientSynchronizer, l2Blockchecker *actions.CheckL2BlockHash) *processor_manager.L1EventProcessors {
13
  p := processor_manager.NewL1EventProcessorsBuilder()
14
  p.Register(incaberry.NewProcessorL1GlobalExitRoot(sync.state))
15
+ p.Register(actions.NewCheckL2BlockDecorator(incaberry.NewProcessorL1SequenceBatches(sync.state, sync.etherMan, sync.pool, sync.eventLog, sync), l2Blockchecker))
16
+ p.Register(actions.NewCheckL2BlockDecorator(incaberry.NewProcessL1ForcedBatches(sync.state), l2Blockchecker))
17
+ p.Register(actions.NewCheckL2BlockDecorator(incaberry.NewProcessL1SequenceForcedBatches(sync.state, sync), l2Blockchecker))
18
  p.Register(incaberry.NewProcessorForkId(sync.state, sync))
19
  p.Register(etrog.NewProcessorL1InfoTreeUpdate(sync.state))
20
  sequenceBatchesProcessor := etrog.NewProcessorL1SequenceBatches(sync.state, sync, common.DefaultTimeProvider{}, sync.halter)
21
+ p.Register(actions.NewCheckL2BlockDecorator(sequenceBatchesProcessor, l2Blockchecker))
22
  p.Register(incaberry.NewProcessorL1VerifyBatch(sync.state))
23
  p.Register(etrog.NewProcessorL1UpdateEtrogSequence(sync.state, sync, common.DefaultTimeProvider{}))
24
+ p.Register(actions.NewCheckL2BlockDecorator(elderberry.NewProcessorL1SequenceBatchesElderberry(sequenceBatchesProcessor, sync.state), l2Blockchecker))
25
  // intialSequence is process in ETROG by the same class, this is just a wrapper to pass directly to ETROG
26
  p.Register(elderberry.NewProcessorL1InitialSequenceBatchesElderberry(sequenceBatchesProcessor))
27
  return p.Build()
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go RENAMED
@@ -31,7 +31,7 @@
31
  GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"),
32
  }
33
 
34
- ethermanClient, err := etherman.NewClient(cfg, l1Config)
35
  require.NoError(t, err)
36
  worker := newWorker(ethermanClient)
37
  ch := make(chan responseRollupInfoByBlockRange)
 
31
  GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"),
32
  }
33
 
34
+ ethermanClient, err := etherman.NewClient(cfg, l1Config, nil)
35
  require.NoError(t, err)
36
  worker := newWorker(ethermanClient)
37
  ch := make(chan responseRollupInfoByBlockRange)
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go RENAMED
@@ -429,6 +430,7 @@
429
  Transactions: data.TrustedBatch.BatchL2Data,
430
  ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)),
431
  SkipVerifyL1InfoRoot_V2: true,
 
432
  }
433
  return request
434
  }
 
430
  Transactions: data.TrustedBatch.BatchL2Data,
431
  ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)),
432
  SkipVerifyL1InfoRoot_V2: true,
433
+ ExecutionMode: executor.ExecutionMode1,
434
  }
435
  return request
436
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go RENAMED
@@ -196,6 +196,7 @@
196
  OldAccInputHash: batches[1].AccInputHash,
197
  Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()),
198
  Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0),
 
199
  }
200
  // check if batch needs to be synchronized
201
  if batches[0] != nil {
 
196
  OldAccInputHash: batches[1].AccInputHash,
197
  Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()),
198
  Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0),
199
+ ExecutionMode: executor.ExecutionMode1,
200
  }
201
  // check if batch needs to be synchronized
202
  if batches[0] != nil {
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go RENAMED
@@ -128,9 +128,28 @@
128
  res.syncTrustedStateExecutor = l2_shared.NewSyncTrustedStateExecutorSelector(map[uint64]syncinterfaces.SyncTrustedStateExecutor{
129
  uint64(state.FORKID_ETROG): syncTrustedStateEtrog,
130
  uint64(state.FORKID_ELDERBERRY): syncTrustedStateEtrog,
 
131
  }, res.state)
132
  }
133
- res.l1EventProcessors = defaultsL1EventProcessors(res)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  switch cfg.L1SynchronizationMode {
135
  case ParallelMode:
136
  log.Info("L1SynchronizationMode is parallel")
@@ -215,7 +234,7 @@
215
  if err != nil {
216
  if errors.Is(err, state.ErrStateNotSynchronized) {
217
  log.Info("State is empty, verifying genesis block")
218
- valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.BlockNumber)
219
  if err != nil {
220
  log.Error("error checking genesis block number. Error: ", err)
221
  return rollback(s.ctx, dbTx, err)
@@ -223,12 +242,42 @@
223
  log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")
224
  return rollback(s.ctx, dbTx, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed"))
225
  }
226
- log.Info("Setting genesis block")
227
- header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.BlockNumber))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  if err != nil {
229
- log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.BlockNumber, err)
230
  return rollback(s.ctx, dbTx, err)
231
  }
 
232
  lastEthBlockSynced = &state.Block{
233
  BlockNumber: header.Number.Uint64(),
234
  BlockHash: header.Hash(),
@@ -717,7 +766,7 @@
717
  return nil, err
718
  }
719
  // Compare hashes
720
- if (block.Hash() != latestBlock.BlockHash || block.ParentHash() != latestBlock.ParentHash) && latestBlock.BlockNumber > s.genesis.BlockNumber {
721
  log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", latestBlock.BlockNumber, block.Hash() == latestBlock.BlockHash, block.ParentHash() == latestBlock.ParentHash)
722
  log.Debug("[checkReorg function] => latestBlockNumber: ", latestBlock.BlockNumber)
723
  log.Debug("[checkReorg function] => latestBlockHash: ", latestBlock.BlockHash)
 
128
  res.syncTrustedStateExecutor = l2_shared.NewSyncTrustedStateExecutorSelector(map[uint64]syncinterfaces.SyncTrustedStateExecutor{
129
  uint64(state.FORKID_ETROG): syncTrustedStateEtrog,
130
  uint64(state.FORKID_ELDERBERRY): syncTrustedStateEtrog,
131
+ uint64(state.FORKID_9): syncTrustedStateEtrog,
132
  }, res.state)
133
  }
134
+ var l1checkerL2Blocks *actions.CheckL2BlockHash
135
+ if cfg.L1SyncCheckL2BlockHash {
136
+ if !isTrustedSequencer {
137
+ log.Infof("Permissionless: L1SyncCheckL2BlockHash is enabled")
138
+ initialL2Block, err := res.state.GetLastL2BlockNumber(res.ctx, nil)
139
+ if errors.Is(err, state.ErrStateNotSynchronized) {
140
+ initialL2Block = 1
141
+ log.Info("State is empty, can't get last L2Block number. Using %d as initial L2Block number", initialL2Block)
142
+ } else if err != nil {
143
+ log.Errorf("error getting last L2Block number from state. Error: %v", err)
144
+ return nil, err
145
+ }
146
+ l1checkerL2Blocks = actions.NewCheckL2BlockHash(res.state, res.zkEVMClient, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus)
147
+ } else {
148
+ log.Infof("Trusted Node can't check L2Block hash, ignoring parameter")
149
+ }
150
+ }
151
+
152
+ res.l1EventProcessors = defaultsL1EventProcessors(res, l1checkerL2Blocks)
153
  switch cfg.L1SynchronizationMode {
154
  case ParallelMode:
155
  log.Info("L1SynchronizationMode is parallel")
 
234
  if err != nil {
235
  if errors.Is(err, state.ErrStateNotSynchronized) {
236
  log.Info("State is empty, verifying genesis block")
237
+ valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.RollupBlockNumber)
238
  if err != nil {
239
  log.Error("error checking genesis block number. Error: ", err)
240
  return rollback(s.ctx, dbTx, err)
 
242
  log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")
243
  return rollback(s.ctx, dbTx, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed"))
244
  }
245
+
246
+ // Sync events from RollupManager that happen before rollup creation
247
+ log.Info("synchronizing events from RollupManager that happen before rollup creation")
248
+ for i := s.genesis.RollupManagerBlockNumber; true; i += s.cfg.SyncChunkSize {
249
+ toBlock := min(i+s.cfg.SyncChunkSize-1, s.genesis.RollupBlockNumber-1)
250
+ blocks, order, err := s.etherMan.GetRollupInfoByBlockRange(s.ctx, i, &toBlock)
251
+ if err != nil {
252
+ log.Error("error getting rollupInfoByBlockRange before rollup genesis: ", err)
253
+ rollbackErr := dbTx.Rollback(s.ctx)
254
+ if rollbackErr != nil {
255
+ log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error())
256
+ return rollbackErr
257
+ }
258
+ return err
259
+ }
260
+ err = s.ProcessBlockRange(blocks, order)
261
+ if err != nil {
262
+ log.Error("error processing blocks before the genesis: ", err)
263
+ rollbackErr := dbTx.Rollback(s.ctx)
264
+ if rollbackErr != nil {
265
+ log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error())
266
+ return rollbackErr
267
+ }
268
+ return err
269
+ }
270
+ if toBlock == s.genesis.RollupBlockNumber-1 {
271
+ break
272
+ }
273
+ }
274
+
275
+ header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.RollupBlockNumber))
276
  if err != nil {
277
+ log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.RollupBlockNumber, err)
278
  return rollback(s.ctx, dbTx, err)
279
  }
280
+ log.Info("synchronizing rollup creation block")
281
  lastEthBlockSynced = &state.Block{
282
  BlockNumber: header.Number.Uint64(),
283
  BlockHash: header.Hash(),
 
766
  return nil, err
767
  }
768
  // Compare hashes
769
+ if (block.Hash() != latestBlock.BlockHash || block.ParentHash() != latestBlock.ParentHash) && latestBlock.BlockNumber > s.genesis.RollupBlockNumber {
770
  log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", latestBlock.BlockNumber, block.Hash() == latestBlock.BlockHash, block.ParentHash() == latestBlock.ParentHash)
771
  log.Debug("[checkReorg function] => latestBlockNumber: ", latestBlock.BlockNumber)
772
  log.Debug("[checkReorg function] => latestBlockHash: ", latestBlock.BlockHash)
{/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go RENAMED
@@ -119,7 +119,7 @@
119
  // but it used a feature that is not implemented in new one that is asking beyond the last block on L1
120
  func TestForcedBatchEtrog(t *testing.T) {
121
  genesis := state.Genesis{
122
- BlockNumber: uint64(123456),
123
  }
124
  cfg := Config{
125
  SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
@@ -372,7 +372,7 @@
372
  // but it used a feature that is not implemented in new one that is asking beyond the last block on L1
373
  func TestSequenceForcedBatchIncaberry(t *testing.T) {
374
  genesis := state.Genesis{
375
- BlockNumber: uint64(123456),
376
  }
377
  cfg := Config{
378
  SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
@@ -611,7 +611,7 @@
611
 
612
  func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) {
613
  genesis := state.Genesis{
614
- BlockNumber: uint64(123456),
615
  }
616
  cfg := Config{
617
  SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
 
119
  // but it used a feature that is not implemented in new one that is asking beyond the last block on L1
120
  func TestForcedBatchEtrog(t *testing.T) {
121
  genesis := state.Genesis{
122
+ RollupBlockNumber: uint64(123456),
123
  }
124
  cfg := Config{
125
  SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
 
372
  // but it used a feature that is not implemented in new one that is asking beyond the last block on L1
373
  func TestSequenceForcedBatchIncaberry(t *testing.T) {
374
  genesis := state.Genesis{
375
+ RollupBlockNumber: uint64(123456),
376
  }
377
  cfg := Config{
378
  SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
 
611
 
612
  func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) {
613
  genesis := state.Genesis{
614
+ RollupBlockNumber: uint64(123456),
615
  }
616
  cfg := Config{
617
  SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol RENAMED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.7.0 <0.9.0;
3
+
4
+ contract customModExp {
5
+ bytes32 hashResult;
6
+ address retEcrecover;
7
+ bytes dataResult;
8
+ uint256 dataRes;
9
+
10
+ bytes32[10] arrayStorage;
11
+
12
+ function modExpGeneric(bytes memory input) public {
13
+ bytes32[10] memory output;
14
+
15
+ assembly {
16
+ let success := staticcall(gas(), 0x05, add(input, 32), mload(input), output, 0x140)
17
+ sstore(0x00, success)
18
+ }
19
+
20
+ for (uint i = 0; i < 10; i++) {
21
+ arrayStorage[i] = output[i];
22
+ }
23
+ }
24
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/Log0.sol RENAMED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // SPDX-License-Identifier: GPL-3.0
2
+ pragma solidity >=0.7.0 <0.9.0;
3
+
4
+ contract Log0 {
5
+ // opcode 0xa0
6
+ function opLog0() public payable {
7
+ assembly {
8
+ log0(0, 32)
9
+ }
10
+ }
11
+
12
+ function opLog00() public payable {
13
+ assembly {
14
+ log0(0, 0)
15
+ }
16
+ }
17
+
18
+ function opLog01() public payable {
19
+ assembly {
20
+ log0(0, 28)
21
+ }
22
+ }
23
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/customModExp/customModExp.go RENAMED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Code generated - DO NOT EDIT.
2
+ // This file is a generated binding and any manual changes will be lost.
3
+
4
+ package customModExp
5
+
6
+ import (
7
+ "errors"
8
+ "math/big"
9
+ "strings"
10
+
11
+ ethereum "github.com/ethereum/go-ethereum"
12
+ "github.com/ethereum/go-ethereum/accounts/abi"
13
+ "github.com/ethereum/go-ethereum/accounts/abi/bind"
14
+ "github.com/ethereum/go-ethereum/common"
15
+ "github.com/ethereum/go-ethereum/core/types"
16
+ "github.com/ethereum/go-ethereum/event"
17
+ )
18
+
19
+ // Reference imports to suppress errors if they are not otherwise used.
20
+ var (
21
+ _ = errors.New
22
+ _ = big.NewInt
23
+ _ = strings.NewReader
24
+ _ = ethereum.NotFound
25
+ _ = bind.Bind
26
+ _ = common.Big1
27
+ _ = types.BloomLookup
28
+ _ = event.NewSubscription
29
+ _ = abi.ConvertType
30
+ )
31
+
32
+ // CustomModExpMetaData contains all meta data concerning the CustomModExp contract.
33
+ var CustomModExpMetaData = &bind.MetaData{
34
+ ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"modExpGeneric\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
35
+ Bin: "0x608060405234801561001057600080fd5b50610208806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063d5665d6f14610030575b600080fd5b61004361003e3660046100e2565b610045565b005b61004d6100ad565b6101408183516020850160055afa60009081555b600a8110156100a8578181600a811061007c5761007c610193565b6020020151600482600a811061009457610094610193565b0155806100a0816101a9565b915050610061565b505050565b604051806101400160405280600a906020820280368337509192915050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156100f457600080fd5b813567ffffffffffffffff8082111561010c57600080fd5b818401915084601f83011261012057600080fd5b813581811115610132576101326100cc565b604051601f8201601f19908116603f0116810190838211818310171561015a5761015a6100cc565b8160405282815287602084870101111561017357600080fd5b826020860160208301376000928101602001929092525095945050505050565b634e487b7160e01b600052603260045260246000fd5b60006000198214156101cb57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212206c4940b4c9a7086754420734c8b4921cdb547ec8b31fc3bf8cd884ad9778a5b364736f6c634300080c0033",
36
+ }
37
+
38
+ // CustomModExpABI is the input ABI used to generate the binding from.
39
+ // Deprecated: Use CustomModExpMetaData.ABI instead.
40
+ var CustomModExpABI = CustomModExpMetaData.ABI
41
+
42
+ // CustomModExpBin is the compiled bytecode used for deploying new contracts.
43
+ // Deprecated: Use CustomModExpMetaData.Bin instead.
44
+ var CustomModExpBin = CustomModExpMetaData.Bin
45
+
46
+ // DeployCustomModExp deploys a new Ethereum contract, binding an instance of CustomModExp to it.
47
+ func DeployCustomModExp(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *CustomModExp, error) {
48
+ parsed, err := CustomModExpMetaData.GetAbi()
49
+ if err != nil {
50
+ return common.Address{}, nil, nil, err
51
+ }
52
+ if parsed == nil {
53
+ return common.Address{}, nil, nil, errors.New("GetABI returned nil")
54
+ }
55
+
56
+ address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CustomModExpBin), backend)
57
+ if err != nil {
58
+ return common.Address{}, nil, nil, err
59
+ }
60
+ return address, tx, &CustomModExp{CustomModExpCaller: CustomModExpCaller{contract: contract}, CustomModExpTransactor: CustomModExpTransactor{contract: contract}, CustomModExpFilterer: CustomModExpFilterer{contract: contract}}, nil
61
+ }
62
+
63
+ // CustomModExp is an auto generated Go binding around an Ethereum contract.
64
+ type CustomModExp struct {
65
+ CustomModExpCaller // Read-only binding to the contract
66
+ CustomModExpTransactor // Write-only binding to the contract
67
+ CustomModExpFilterer // Log filterer for contract events
68
+ }
69
+
70
+ // CustomModExpCaller is an auto generated read-only Go binding around an Ethereum contract.
71
+ type CustomModExpCaller struct {
72
+ contract *bind.BoundContract // Generic contract wrapper for the low level calls
73
+ }
74
+
75
+ // CustomModExpTransactor is an auto generated write-only Go binding around an Ethereum contract.
76
+ type CustomModExpTransactor struct {
77
+ contract *bind.BoundContract // Generic contract wrapper for the low level calls
78
+ }
79
+
80
+ // CustomModExpFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
81
+ type CustomModExpFilterer struct {
82
+ contract *bind.BoundContract // Generic contract wrapper for the low level calls
83
+ }
84
+
85
+ // CustomModExpSession is an auto generated Go binding around an Ethereum contract,
86
+ // with pre-set call and transact options.
87
+ type CustomModExpSession struct {
88
+ Contract *CustomModExp // Generic contract binding to set the session for
89
+ CallOpts bind.CallOpts // Call options to use throughout this session
90
+ TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
91
+ }
92
+
93
+ // CustomModExpCallerSession is an auto generated read-only Go binding around an Ethereum contract,
94
+ // with pre-set call options.
95
+ type CustomModExpCallerSession struct {
96
+ Contract *CustomModExpCaller // Generic contract caller binding to set the session for
97
+ CallOpts bind.CallOpts // Call options to use throughout this session
98
+ }
99
+
100
+ // CustomModExpTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
101
+ // with pre-set transact options.
102
+ type CustomModExpTransactorSession struct {
103
+ Contract *CustomModExpTransactor // Generic contract transactor binding to set the session for
104
+ TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
105
+ }
106
+
107
+ // CustomModExpRaw is an auto generated low-level Go binding around an Ethereum contract.
108
+ type CustomModExpRaw struct {
109
+ Contract *CustomModExp // Generic contract binding to access the raw methods on
110
+ }
111
+
112
+ // CustomModExpCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
113
+ type CustomModExpCallerRaw struct {
114
+ Contract *CustomModExpCaller // Generic read-only contract binding to access the raw methods on
115
+ }
116
+
117
+ // CustomModExpTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
118
+ type CustomModExpTransactorRaw struct {
119
+ Contract *CustomModExpTransactor // Generic write-only contract binding to access the raw methods on
120
+ }
121
+
122
+ // NewCustomModExp creates a new instance of CustomModExp, bound to a specific deployed contract.
123
+ func NewCustomModExp(address common.Address, backend bind.ContractBackend) (*CustomModExp, error) {
124
+ contract, err := bindCustomModExp(address, backend, backend, backend)
125
+ if err != nil {
126
+ return nil, err
127
+ }
128
+ return &CustomModExp{CustomModExpCaller: CustomModExpCaller{contract: contract}, CustomModExpTransactor: CustomModExpTransactor{contract: contract}, CustomModExpFilterer: CustomModExpFilterer{contract: contract}}, nil
129
+ }
130
+
131
+ // NewCustomModExpCaller creates a new read-only instance of CustomModExp, bound to a specific deployed contract.
132
+ func NewCustomModExpCaller(address common.Address, caller bind.ContractCaller) (*CustomModExpCaller, error) {
133
+ contract, err := bindCustomModExp(address, caller, nil, nil)
134
+ if err != nil {
135
+ return nil, err
136
+ }
137
+ return &CustomModExpCaller{contract: contract}, nil
138
+ }
139
+
140
+ // NewCustomModExpTransactor creates a new write-only instance of CustomModExp, bound to a specific deployed contract.
141
+ func NewCustomModExpTransactor(address common.Address, transactor bind.ContractTransactor) (*CustomModExpTransactor, error) {
142
+ contract, err := bindCustomModExp(address, nil, transactor, nil)
143
+ if err != nil {
144
+ return nil, err
145
+ }
146
+ return &CustomModExpTransactor{contract: contract}, nil
147
+ }
148
+
149
+ // NewCustomModExpFilterer creates a new log filterer instance of CustomModExp, bound to a specific deployed contract.
150
+ func NewCustomModExpFilterer(address common.Address, filterer bind.ContractFilterer) (*CustomModExpFilterer, error) {
151
+ contract, err := bindCustomModExp(address, nil, nil, filterer)
152
+ if err != nil {
153
+ return nil, err
154
+ }
155
+ return &CustomModExpFilterer{contract: contract}, nil
156
+ }
157
+
158
+ // bindCustomModExp binds a generic wrapper to an already deployed contract.
159
+ func bindCustomModExp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
160
+ parsed, err := CustomModExpMetaData.GetAbi()
161
+ if err != nil {
162
+ return nil, err
163
+ }
164
+ return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil
165
+ }
166
+
167
+ // Call invokes the (constant) contract method with params as input values and
168
+ // sets the output to result. The result type might be a single field for simple
169
+ // returns, a slice of interfaces for anonymous returns and a struct for named
170
+ // returns.
171
+ func (_CustomModExp *CustomModExpRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
172
+ return _CustomModExp.Contract.CustomModExpCaller.contract.Call(opts, result, method, params...)
173
+ }
174
+
175
+ // Transfer initiates a plain transaction to move funds to the contract, calling
176
+ // its default method if one is available.
177
+ func (_CustomModExp *CustomModExpRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
178
+ return _CustomModExp.Contract.CustomModExpTransactor.contract.Transfer(opts)
179
+ }
180
+
181
+ // Transact invokes the (paid) contract method with params as input values.
182
+ func (_CustomModExp *CustomModExpRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
183
+ return _CustomModExp.Contract.CustomModExpTransactor.contract.Transact(opts, method, params...)
184
+ }
185
+
186
+ // Call invokes the (constant) contract method with params as input values and
187
+ // sets the output to result. The result type might be a single field for simple
188
+ // returns, a slice of interfaces for anonymous returns and a struct for named
189
+ // returns.
190
+ func (_CustomModExp *CustomModExpCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
191
+ return _CustomModExp.Contract.contract.Call(opts, result, method, params...)
192
+ }
193
+
194
+ // Transfer initiates a plain transaction to move funds to the contract, calling
195
+ // its default method if one is available.
196
+ func (_CustomModExp *CustomModExpTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
197
+ return _CustomModExp.Contract.contract.Transfer(opts)
198
+ }
199
+
200
+ // Transact invokes the (paid) contract method with params as input values.
201
+ func (_CustomModExp *CustomModExpTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
202
+ return _CustomModExp.Contract.contract.Transact(opts, method, params...)
203
+ }
204
+
205
+ // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f.
206
+ //
207
+ // Solidity: function modExpGeneric(bytes input) returns()
208
+ func (_CustomModExp *CustomModExpTransactor) ModExpGeneric(opts *bind.TransactOpts, input []byte) (*types.Transaction, error) {
209
+ return _CustomModExp.contract.Transact(opts, "modExpGeneric", input)
210
+ }
211
+
212
+ // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f.
213
+ //
214
+ // Solidity: function modExpGeneric(bytes input) returns()
215
+ func (_CustomModExp *CustomModExpSession) ModExpGeneric(input []byte) (*types.Transaction, error) {
216
+ return _CustomModExp.Contract.ModExpGeneric(&_CustomModExp.TransactOpts, input)
217
+ }
218
+
219
+ // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f.
220
+ //
221
+ // Solidity: function modExpGeneric(bytes input) returns()
222
+ func (_CustomModExp *CustomModExpTransactorSession) ModExpGeneric(input []byte) (*types.Transaction, error) {
223
+ return _CustomModExp.Contract.ModExpGeneric(&_CustomModExp.TransactOpts, input)
224
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/Log0/Log0.go RENAMED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Code generated - DO NOT EDIT.
2
+ // This file is a generated binding and any manual changes will be lost.
3
+
4
+ package Log0
5
+
6
+ import (
7
+ "errors"
8
+ "math/big"
9
+ "strings"
10
+
11
+ ethereum "github.com/ethereum/go-ethereum"
12
+ "github.com/ethereum/go-ethereum/accounts/abi"
13
+ "github.com/ethereum/go-ethereum/accounts/abi/bind"
14
+ "github.com/ethereum/go-ethereum/common"
15
+ "github.com/ethereum/go-ethereum/core/types"
16
+ "github.com/ethereum/go-ethereum/event"
17
+ )
18
+
19
+ // Reference imports to suppress errors if they are not otherwise used.
20
+ var (
21
+ _ = errors.New
22
+ _ = big.NewInt
23
+ _ = strings.NewReader
24
+ _ = ethereum.NotFound
25
+ _ = bind.Bind
26
+ _ = common.Big1
27
+ _ = types.BloomLookup
28
+ _ = event.NewSubscription
29
+ _ = abi.ConvertType
30
+ )
31
+
32
+ // Log0MetaData contains all meta data concerning the Log0 contract.
33
+ var Log0MetaData = &bind.MetaData{
34
+ ABI: "[{\"inputs\":[],\"name\":\"opLog0\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"opLog00\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"opLog01\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}]",
35
+ Bin: "0x6080604052348015600f57600080fd5b5060938061001e6000396000f3fe60806040526004361060305760003560e01c80633e2d0b8514603557806357e4605514603d578063ecc5544a146043575b600080fd5b603b6049565b005b603b6050565b603b6056565b601c6000a0565b600080a0565b60206000a056fea26469706673582212209aba01a729d89e6da96ac8ca0b8f1940565356ed4f7849c9af7a95f5188d22d964736f6c634300080c0033",
36
+ }
37
+
38
+ // Log0ABI is the input ABI used to generate the binding from.
39
+ // Deprecated: Use Log0MetaData.ABI instead.
40
+ var Log0ABI = Log0MetaData.ABI
41
+
42
+ // Log0Bin is the compiled bytecode used for deploying new contracts.
43
+ // Deprecated: Use Log0MetaData.Bin instead.
44
+ var Log0Bin = Log0MetaData.Bin
45
+
46
+ // DeployLog0 deploys a new Ethereum contract, binding an instance of Log0 to it.
47
+ func DeployLog0(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Log0, error) {
48
+ parsed, err := Log0MetaData.GetAbi()
49
+ if err != nil {
50
+ return common.Address{}, nil, nil, err
51
+ }
52
+ if parsed == nil {
53
+ return common.Address{}, nil, nil, errors.New("GetABI returned nil")
54
+ }
55
+
56
+ address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(Log0Bin), backend)
57
+ if err != nil {
58
+ return common.Address{}, nil, nil, err
59
+ }
60
+ return address, tx, &Log0{Log0Caller: Log0Caller{contract: contract}, Log0Transactor: Log0Transactor{contract: contract}, Log0Filterer: Log0Filterer{contract: contract}}, nil
61
+ }
62
+
63
+ // Log0 is an auto generated Go binding around an Ethereum contract.
64
+ type Log0 struct {
65
+ Log0Caller // Read-only binding to the contract
66
+ Log0Transactor // Write-only binding to the contract
67
+ Log0Filterer // Log filterer for contract events
68
+ }
69
+
70
+ // Log0Caller is an auto generated read-only Go binding around an Ethereum contract.
71
+ type Log0Caller struct {
72
+ contract *bind.BoundContract // Generic contract wrapper for the low level calls
73
+ }
74
+
75
+ // Log0Transactor is an auto generated write-only Go binding around an Ethereum contract.
76
+ type Log0Transactor struct {
77
+ contract *bind.BoundContract // Generic contract wrapper for the low level calls
78
+ }
79
+
80
+ // Log0Filterer is an auto generated log filtering Go binding around an Ethereum contract events.
81
+ type Log0Filterer struct {
82
+ contract *bind.BoundContract // Generic contract wrapper for the low level calls
83
+ }
84
+
85
+ // Log0Session is an auto generated Go binding around an Ethereum contract,
86
+ // with pre-set call and transact options.
87
+ type Log0Session struct {
88
+ Contract *Log0 // Generic contract binding to set the session for
89
+ CallOpts bind.CallOpts // Call options to use throughout this session
90
+ TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
91
+ }
92
+
93
+ // Log0CallerSession is an auto generated read-only Go binding around an Ethereum contract,
94
+ // with pre-set call options.
95
+ type Log0CallerSession struct {
96
+ Contract *Log0Caller // Generic contract caller binding to set the session for
97
+ CallOpts bind.CallOpts // Call options to use throughout this session
98
+ }
99
+
100
+ // Log0TransactorSession is an auto generated write-only Go binding around an Ethereum contract,
101
+ // with pre-set transact options.
102
+ type Log0TransactorSession struct {
103
+ Contract *Log0Transactor // Generic contract transactor binding to set the session for
104
+ TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
105
+ }
106
+
107
+ // Log0Raw is an auto generated low-level Go binding around an Ethereum contract.
108
+ type Log0Raw struct {
109
+ Contract *Log0 // Generic contract binding to access the raw methods on
110
+ }
111
+
112
+ // Log0CallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
113
+ type Log0CallerRaw struct {
114
+ Contract *Log0Caller // Generic read-only contract binding to access the raw methods on
115
+ }
116
+
117
+ // Log0TransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
118
+ type Log0TransactorRaw struct {
119
+ Contract *Log0Transactor // Generic write-only contract binding to access the raw methods on
120
+ }
121
+
122
+ // NewLog0 creates a new instance of Log0, bound to a specific deployed contract.
123
+ func NewLog0(address common.Address, backend bind.ContractBackend) (*Log0, error) {
124
+ contract, err := bindLog0(address, backend, backend, backend)
125
+ if err != nil {
126
+ return nil, err
127
+ }
128
+ return &Log0{Log0Caller: Log0Caller{contract: contract}, Log0Transactor: Log0Transactor{contract: contract}, Log0Filterer: Log0Filterer{contract: contract}}, nil
129
+ }
130
+
131
+ // NewLog0Caller creates a new read-only instance of Log0, bound to a specific deployed contract.
132
+ func NewLog0Caller(address common.Address, caller bind.ContractCaller) (*Log0Caller, error) {
133
+ contract, err := bindLog0(address, caller, nil, nil)
134
+ if err != nil {
135
+ return nil, err
136
+ }
137
+ return &Log0Caller{contract: contract}, nil
138
+ }
139
+
140
+ // NewLog0Transactor creates a new write-only instance of Log0, bound to a specific deployed contract.
141
+ func NewLog0Transactor(address common.Address, transactor bind.ContractTransactor) (*Log0Transactor, error) {
142
+ contract, err := bindLog0(address, nil, transactor, nil)
143
+ if err != nil {
144
+ return nil, err
145
+ }
146
+ return &Log0Transactor{contract: contract}, nil
147
+ }
148
+
149
+ // NewLog0Filterer creates a new log filterer instance of Log0, bound to a specific deployed contract.
150
+ func NewLog0Filterer(address common.Address, filterer bind.ContractFilterer) (*Log0Filterer, error) {
151
+ contract, err := bindLog0(address, nil, nil, filterer)
152
+ if err != nil {
153
+ return nil, err
154
+ }
155
+ return &Log0Filterer{contract: contract}, nil
156
+ }
157
+
158
+ // bindLog0 binds a generic wrapper to an already deployed contract.
159
+ func bindLog0(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
160
+ parsed, err := Log0MetaData.GetAbi()
161
+ if err != nil {
162
+ return nil, err
163
+ }
164
+ return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil
165
+ }
166
+
167
+ // Call invokes the (constant) contract method with params as input values and
168
+ // sets the output to result. The result type might be a single field for simple
169
+ // returns, a slice of interfaces for anonymous returns and a struct for named
170
+ // returns.
171
+ func (_Log0 *Log0Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
172
+ return _Log0.Contract.Log0Caller.contract.Call(opts, result, method, params...)
173
+ }
174
+
175
+ // Transfer initiates a plain transaction to move funds to the contract, calling
176
+ // its default method if one is available.
177
+ func (_Log0 *Log0Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
178
+ return _Log0.Contract.Log0Transactor.contract.Transfer(opts)
179
+ }
180
+
181
+ // Transact invokes the (paid) contract method with params as input values.
182
+ func (_Log0 *Log0Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
183
+ return _Log0.Contract.Log0Transactor.contract.Transact(opts, method, params...)
184
+ }
185
+
186
+ // Call invokes the (constant) contract method with params as input values and
187
+ // sets the output to result. The result type might be a single field for simple
188
+ // returns, a slice of interfaces for anonymous returns and a struct for named
189
+ // returns.
190
+ func (_Log0 *Log0CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
191
+ return _Log0.Contract.contract.Call(opts, result, method, params...)
192
+ }
193
+
194
+ // Transfer initiates a plain transaction to move funds to the contract, calling
195
+ // its default method if one is available.
196
+ func (_Log0 *Log0TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
197
+ return _Log0.Contract.contract.Transfer(opts)
198
+ }
199
+
200
+ // Transact invokes the (paid) contract method with params as input values.
201
+ func (_Log0 *Log0TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
202
+ return _Log0.Contract.contract.Transact(opts, method, params...)
203
+ }
204
+
205
+ // OpLog0 is a paid mutator transaction binding the contract method 0xecc5544a.
206
+ //
207
+ // Solidity: function opLog0() payable returns()
208
+ func (_Log0 *Log0Transactor) OpLog0(opts *bind.TransactOpts) (*types.Transaction, error) {
209
+ return _Log0.contract.Transact(opts, "opLog0")
210
+ }
211
+
212
+ // OpLog0 is a paid mutator transaction binding the contract method 0xecc5544a.
213
+ //
214
+ // Solidity: function opLog0() payable returns()
215
+ func (_Log0 *Log0Session) OpLog0() (*types.Transaction, error) {
216
+ return _Log0.Contract.OpLog0(&_Log0.TransactOpts)
217
+ }
218
+
219
+ // OpLog0 is a paid mutator transaction binding the contract method 0xecc5544a.
220
+ //
221
+ // Solidity: function opLog0() payable returns()
222
+ func (_Log0 *Log0TransactorSession) OpLog0() (*types.Transaction, error) {
223
+ return _Log0.Contract.OpLog0(&_Log0.TransactOpts)
224
+ }
225
+
226
+ // OpLog00 is a paid mutator transaction binding the contract method 0x57e46055.
227
+ //
228
+ // Solidity: function opLog00() payable returns()
229
+ func (_Log0 *Log0Transactor) OpLog00(opts *bind.TransactOpts) (*types.Transaction, error) {
230
+ return _Log0.contract.Transact(opts, "opLog00")
231
+ }
232
+
233
+ // OpLog00 is a paid mutator transaction binding the contract method 0x57e46055.
234
+ //
235
+ // Solidity: function opLog00() payable returns()
236
+ func (_Log0 *Log0Session) OpLog00() (*types.Transaction, error) {
237
+ return _Log0.Contract.OpLog00(&_Log0.TransactOpts)
238
+ }
239
+
240
+ // OpLog00 is a paid mutator transaction binding the contract method 0x57e46055.
241
+ //
242
+ // Solidity: function opLog00() payable returns()
243
+ func (_Log0 *Log0TransactorSession) OpLog00() (*types.Transaction, error) {
244
+ return _Log0.Contract.OpLog00(&_Log0.TransactOpts)
245
+ }
246
+
247
+ // OpLog01 is a paid mutator transaction binding the contract method 0x3e2d0b85.
248
+ //
249
+ // Solidity: function opLog01() payable returns()
250
+ func (_Log0 *Log0Transactor) OpLog01(opts *bind.TransactOpts) (*types.Transaction, error) {
251
+ return _Log0.contract.Transact(opts, "opLog01")
252
+ }
253
+
254
+ // OpLog01 is a paid mutator transaction binding the contract method 0x3e2d0b85.
255
+ //
256
+ // Solidity: function opLog01() payable returns()
257
+ func (_Log0 *Log0Session) OpLog01() (*types.Transaction, error) {
258
+ return _Log0.Contract.OpLog01(&_Log0.TransactOpts)
259
+ }
260
+
261
+ // OpLog01 is a paid mutator transaction binding the contract method 0x3e2d0b85.
262
+ //
263
+ // Solidity: function opLog01() payable returns()
264
+ func (_Log0 *Log0TransactorSession) OpLog01() (*types.Transaction, error) {
265
+ return _Log0.Contract.OpLog01(&_Log0.TransactOpts)
266
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/triggerErrors/triggerErrors.go RENAMED
@@ -32,7 +32,7 @@
32
  // TriggerErrorsMetaData contains all meta data concerning the TriggerErrors contract.
33
  var TriggerErrorsMetaData = &bind.MetaData{
34
  ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersKeccaks\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"test\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersPoseidon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersSteps\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
35
- Bin: "0x60806040526000805534801561001457600080fd5b5061016c806100246000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306661abd1461005c5780632621002a1461007757806331fe52e8146100835780638bd7b5381461008d578063cb4e8cd114610095575b600080fd5b61006560005481565b60405190815260200160405180910390f35b620f4240600020610065565b61008b61009d565b005b61008b6100c3565b61008b6100e9565b60005b60648110156100c0578060005580806100b89061010d565b9150506100a0565b50565b60005b620186a08110156100c0576104d2600052806100e18161010d565b9150506100c6565b60005b61c3508110156100c0578060005580806101059061010d565b9150506100ec565b600060001982141561012f57634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122097beacfaa873e4896937143dfea406cc278b929a28023f7e7020b6dea6e9fc7364736f6c634300080c0033",
36
  }
37
 
38
  // TriggerErrorsABI is the input ABI used to generate the binding from.
 
32
  // TriggerErrorsMetaData contains all meta data concerning the TriggerErrors contract.
33
  var TriggerErrorsMetaData = &bind.MetaData{
34
  ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersKeccaks\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"test\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersPoseidon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersSteps\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
35
+ Bin: "0x60806040526000805534801561001457600080fd5b5061016c806100246000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306661abd1461005c5780632621002a1461007757806331fe52e8146100835780638bd7b5381461008d578063cb4e8cd114610095575b600080fd5b61006560005481565b60405190815260200160405180910390f35b620f4240600020610065565b61008b61009d565b005b61008b6100c3565b61008b6100e9565b60005b60648110156100c0578060005580806100b89061010d565b9150506100a0565b50565b60005b620186a08110156100c0576104d2600052806100e18161010d565b9150506100c6565b60005b61c3508110156100c0578060005580806101059061010d565b9150506100ec565b600060001982141561012f57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212208f01c5dc055b1f376f5da5deb33e2c96ee776174bf48874c5ebba0f606de2ac564736f6c634300080c0033",
36
  }
37
 
38
  // TriggerErrorsABI is the input ABI used to generate the binding from.
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml RENAMED
@@ -2,7 +2,7 @@
2
  networks:
3
  default:
4
  name: zkevm
5
-
6
  services:
7
  grafana:
8
  container_name: grafana
@@ -453,7 +453,7 @@
453
 
454
  zkevm-mock-l1-network:
455
  container_name: zkevm-mock-l1-network
456
- image: hermeznetwork/geth-zkevm-contracts:v2.1.3-fork.8-geth1.12.0
457
  ports:
458
  - 8545:8545
459
  - 8546:8546
@@ -513,12 +513,14 @@
513
 
514
  zkevm-prover:
515
  container_name: zkevm-prover
516
- image: hermeznetwork/zkevm-prover:v5.0.3
517
  ports:
518
  - 50061:50061 # MT
519
  - 50071:50071 # Executor
520
  volumes:
521
  - ./config/test.prover.config.json:/usr/src/app/config.json
 
 
522
  command: >
523
  zkProver -c /usr/src/app/config.json
524
 
@@ -602,7 +604,7 @@
602
 
603
  zkevm-permissionless-prover:
604
  container_name: zkevm-permissionless-prover
605
- image: hermeznetwork/zkevm-prover:v5.0.3
606
  ports:
607
  # - 50058:50058 # Prover
608
  - 50059:50052 # Mock prover
@@ -628,7 +630,7 @@
628
  zkevm-sh:
629
  container_name: zkevm-sh
630
  image: zkevm-node
631
- stdin_open: true
632
  tty: true
633
  environment:
634
  - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db
@@ -638,3 +640,51 @@
638
  - ./config/test.genesis.config.json:/app/genesis.json
639
  command:
640
  - "/bin/sh"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  networks:
3
  default:
4
  name: zkevm
5
+
6
  services:
7
  grafana:
8
  container_name: grafana
 
453
 
454
  zkevm-mock-l1-network:
455
  container_name: zkevm-mock-l1-network
456
+ image: 0xpolygon/cdk-validium-contracts:forkId8
457
  ports:
458
  - 8545:8545
459
  - 8546:8546
 
513
 
514
  zkevm-prover:
515
  container_name: zkevm-prover
516
+ image: hermeznetwork/zkevm-prover:v6.0.0
517
  ports:
518
  - 50061:50061 # MT
519
  - 50071:50071 # Executor
520
  volumes:
521
  - ./config/test.prover.config.json:/usr/src/app/config.json
522
+ environment:
523
+ - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1
524
  command: >
525
  zkProver -c /usr/src/app/config.json
526
 
 
604
 
605
  zkevm-permissionless-prover:
606
  container_name: zkevm-permissionless-prover
607
+ image: hermeznetwork/zkevm-prover:v6.0.0
608
  ports:
609
  # - 50058:50058 # Prover
610
  - 50059:50052 # Mock prover
 
630
  zkevm-sh:
631
  container_name: zkevm-sh
632
  image: zkevm-node
633
+ stdin_open: true
634
  tty: true
635
  environment:
636
  - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db
 
640
  - ./config/test.genesis.config.json:/app/genesis.json
641
  command:
642
  - "/bin/sh"
643
+
644
+ zkevm-node-forced-DAC:
645
+ container_name: zkevm-node-forced-DAC
646
+ image: zkevm-node
647
+ ports:
648
+ - 8125:8125
649
+ environment:
650
+ - ZKEVM_NODE_ISTRUSTEDSEQUENCER=false
651
+ - ZKEVM_NODE_STATEDB_USER=test_user
652
+ - ZKEVM_NODE_STATEDB_PASSWORD=test_password
653
+ - ZKEVM_NODE_STATEDB_NAME=state_db
654
+ - ZKEVM_NODE_STATEDB_HOST=zkevm-permissionless-db
655
+ - ZKEVM_NODE_POOL_DB_USER=test_user
656
+ - ZKEVM_NODE_POOL_DB_PASSWORD=test_password
657
+ - ZKEVM_NODE_POOL_DB_NAME=pool_db
658
+ - ZKEVM_NODE_POOL_DB_HOST=zkevm-permissionless-db
659
+ - ZKEVM_NODE_RPC_PORT=8125
660
+ - ZKEVM_NODE_RPC_SEQUENCERNODEURI=http://zkevm-node-json-rpc:8123
661
+ - ZKEVM_NODE_SYNCHRONIZER_TRUSTEDSEQUENCERURL=http://you-cant-touch-this:8123
662
+ - ZKEVM_NODE_MTCLIENT_URI=zkevm-permissionless-prover:50061
663
+ - ZKEVM_NODE_EXECUTOR_URI=zkevm-permissionless-prover:50071
664
+ volumes:
665
+ - ./config/test.node.config.toml:/app/config.toml
666
+ - ./config/test.genesis.config.json:/app/genesis.json
667
+ command:
668
+ - "/bin/sh"
669
+ - "-c"
670
+ - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components \"rpc,synchronizer\""
671
+
672
+ zkevm-data-node-db:
673
+ container_name: zkevm-data-node-db
674
+ restart: unless-stopped
675
+ image: postgres
676
+ healthcheck:
677
+ test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
678
+ interval: 10s
679
+ timeout: 5s
680
+ retries: 5
681
+ ports:
682
+ - 5444:5432
683
+ environment:
684
+ - POSTGRES_USER=committee_user
685
+ - POSTGRES_PASSWORD=committee_password
686
+ - POSTGRES_DB=committee_db
687
+ command:
688
+ - "postgres"
689
+ - "-N"
690
+ - "500"
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/datacommittee_test.go RENAMED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package e2e
2
+
3
+ import (
4
+ "context"
5
+ "crypto/ecdsa"
6
+ "encoding/json"
7
+ "fmt"
8
+ "math/big"
9
+ "os"
10
+ "os/exec"
11
+ "sort"
12
+ "strconv"
13
+ "strings"
14
+ "testing"
15
+ "time"
16
+
17
+ "github.com/0xPolygon/cdk-data-availability/config"
18
+ cTypes "github.com/0xPolygon/cdk-data-availability/config/types"
19
+ "github.com/0xPolygon/cdk-data-availability/db"
20
+ "github.com/0xPolygon/cdk-data-availability/rpc"
21
+ "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee"
22
+ "github.com/0xPolygonHermez/zkevm-node/log"
23
+ "github.com/0xPolygonHermez/zkevm-node/test/operations"
24
+ "github.com/ethereum/go-ethereum"
25
+ eTypes "github.com/ethereum/go-ethereum/core/types"
26
+
27
+ "github.com/ethereum/go-ethereum/accounts/keystore"
28
+ "github.com/ethereum/go-ethereum/common"
29
+ "github.com/ethereum/go-ethereum/crypto"
30
+ "github.com/ethereum/go-ethereum/ethclient"
31
+ "github.com/stretchr/testify/assert"
32
+ "github.com/stretchr/testify/require"
33
+ )
34
+
35
+ func TestDataCommittee(t *testing.T) {
36
+ const (
37
+ nSignatures = 4
38
+ mMembers = 5
39
+ ksFile = "/tmp/pkey"
40
+ cfgFile = "/tmp/dacnodeconfigfile.json"
41
+ ksPass = "pass"
42
+ dacNodeContainer = "hermeznetwork/cdk-data-availability:v0.0.4"
43
+ )
44
+
45
+ // Setup
46
+ var err error
47
+ if testing.Short() {
48
+ t.Skip()
49
+ }
50
+ ctx := context.Background()
51
+ defer func() {
52
+ require.NoError(t, operations.Teardown())
53
+ }()
54
+ err = operations.Teardown()
55
+ require.NoError(t, err)
56
+ opsCfg := operations.GetDefaultOperationsConfig()
57
+ opsCfg.State.MaxCumulativeGasUsed = 80000000000
58
+ opsman, err := operations.NewManager(ctx, opsCfg)
59
+ require.NoError(t, err)
60
+ defer func() {
61
+ require.NoError(t, opsman.StopDACDB())
62
+ }()
63
+ err = opsman.Setup()
64
+ require.NoError(t, err)
65
+ require.NoError(t, opsman.StartDACDB())
66
+ time.Sleep(5 * time.Second)
67
+ authL2, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL2ChainID)
68
+ require.NoError(t, err)
69
+ authL1, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL1ChainID)
70
+ require.NoError(t, err)
71
+ clientL2, err := ethclient.Dial(operations.DefaultL2NetworkURL)
72
+ require.NoError(t, err)
73
+ clientL1, err := ethclient.Dial(operations.DefaultL1NetworkURL)
74
+ require.NoError(t, err)
75
+ dacSC, err := polygondatacommittee.NewPolygondatacommittee(
76
+ common.HexToAddress(operations.DefaultL1DataCommitteeContract),
77
+ clientL1,
78
+ )
79
+ require.NoError(t, err)
80
+
81
+ // Register committe with N / M signatures
82
+ membs := members{}
83
+ addrsBytes := []byte{}
84
+ urls := []string{}
85
+ for i := 0; i < mMembers; i++ {
86
+ pk, err := crypto.GenerateKey()
87
+ require.NoError(t, err)
88
+ membs = append(membs, member{
89
+ addr: crypto.PubkeyToAddress(pk.PublicKey),
90
+ pk: pk,
91
+ url: fmt.Sprintf("http://cdk-data-availability-%d:420%d", i, i),
92
+ i: i,
93
+ })
94
+ }
95
+ sort.Sort(membs)
96
+ for _, m := range membs {
97
+ addrsBytes = append(addrsBytes, m.addr.Bytes()...)
98
+ urls = append(urls, m.url)
99
+ }
100
+ tx, err := dacSC.SetupCommittee(authL1, big.NewInt(nSignatures), urls, addrsBytes)
101
+ for _, m := range membs {
102
+ fmt.Println(m.addr)
103
+ }
104
+ require.NoError(t, err)
105
+ err = operations.WaitTxToBeMined(ctx, clientL1, tx, operations.DefaultTimeoutTxToBeMined)
106
+ require.NoError(t, err)
107
+
108
+ // Spin up M DAC nodes
109
+ dacNodeConfig := config.Config{
110
+ L1: config.L1Config{
111
+ RpcURL: "http://zkevm-mock-l1-network:8545",
112
+ WsURL: "ws://zkevm-mock-l1-network:8546",
113
+ PolygonValidiumAddress: operations.DefaultL1ZkEVMSmartContract,
114
+ DataCommitteeAddress: operations.DefaultL1DataCommitteeContract,
115
+ Timeout: cTypes.Duration{Duration: time.Second},
116
+ RetryPeriod: cTypes.Duration{Duration: time.Second},
117
+ },
118
+ PrivateKey: cTypes.KeystoreFileConfig{
119
+ Path: ksFile,
120
+ Password: ksPass,
121
+ },
122
+ DB: db.Config{
123
+ Name: "committee_db",
124
+ User: "committee_user",
125
+ Password: "committee_password",
126
+ Host: "zkevm-data-node-db",
127
+ Port: "5432",
128
+ EnableLog: false,
129
+ MaxConns: 10,
130
+ },
131
+ RPC: rpc.Config{
132
+ Host: "0.0.0.0",
133
+ MaxRequestsPerIPAndSecond: 100,
134
+ },
135
+ }
136
+ defer func() {
137
+ // Remove tmp files
138
+ assert.NoError(t,
139
+ exec.Command("rm", cfgFile).Run(),
140
+ )
141
+ assert.NoError(t,
142
+ exec.Command("rmdir", ksFile+"_").Run(),
143
+ )
144
+ assert.NoError(t,
145
+ exec.Command("rm", ksFile).Run(),
146
+ )
147
+ // Stop DAC nodes
148
+ for i := 0; i < mMembers; i++ {
149
+ assert.NoError(t, exec.Command(
150
+ "docker", "kill", "cdk-data-availability-"+strconv.Itoa(i),
151
+ ).Run())
152
+ assert.NoError(t, exec.Command(
153
+ "docker", "rm", "cdk-data-availability-"+strconv.Itoa(i),
154
+ ).Run())
155
+ }
156
+ // Stop permissionless node
157
+ require.NoError(t, opsman.StopPermissionlessNodeForcedToSYncThroughDAC())
158
+ }()
159
+ // Start permissionless node
160
+ require.NoError(t, opsman.StartPermissionlessNodeForcedToSYncThroughDAC())
161
+ // Star DAC nodes
162
+ for _, m := range membs {
163
+ // Set correct port
164
+ port := 4200 + m.i
165
+ dacNodeConfig.RPC.Port = port
166
+ // Write config file
167
+ file, err := json.MarshalIndent(dacNodeConfig, "", " ")
168
+ require.NoError(t, err)
169
+ err = os.WriteFile(cfgFile, file, 0644)
170
+ require.NoError(t, err)
171
+ // Write private key keystore file
172
+ err = createKeyStore(m.pk, ksFile, ksPass)
173
+ require.NoError(t, err)
174
+ // Run DAC node
175
+ cmd := exec.Command(
176
+ "docker", "run", "-d",
177
+ "--name", "cdk-data-availability-"+strconv.Itoa(m.i),
178
+ "-v", cfgFile+":/app/config.json",
179
+ "-v", ksFile+":"+ksFile,
180
+ "--network", "zkevm",
181
+ dacNodeContainer,
182
+ "/bin/sh", "-c",
183
+ "/app/cdk-data-availability run --cfg /app/config.json",
184
+ )
185
+ out, err := cmd.CombinedOutput()
186
+ require.NoError(t, err, string(out))
187
+ log.Infof("DAC node %d started", m.i)
188
+ time.Sleep(time.Second * 5)
189
+ }
190
+
191
+ // Send txs
192
+ nTxs := 10
193
+ amount := big.NewInt(10000)
194
+ toAddress := common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8")
195
+ _, err = clientL2.BalanceAt(ctx, authL2.From, nil)
196
+ require.NoError(t, err)
197
+ _, err = clientL2.PendingNonceAt(ctx, authL2.From)
198
+ require.NoError(t, err)
199
+
200
+ gasLimit, err := clientL2.EstimateGas(ctx, ethereum.CallMsg{From: authL2.From, To: &toAddress, Value: amount})
201
+ require.NoError(t, err)
202
+
203
+ gasPrice, err := clientL2.SuggestGasPrice(ctx)
204
+ require.NoError(t, err)
205
+
206
+ nonce, err := clientL2.PendingNonceAt(ctx, authL2.From)
207
+ require.NoError(t, err)
208
+
209
+ txs := make([]*eTypes.Transaction, 0, nTxs)
210
+ for i := 0; i < nTxs; i++ {
211
+ tx := eTypes.NewTransaction(nonce+uint64(i), toAddress, amount, gasLimit, gasPrice, nil)
212
+ log.Infof("generating tx %d / %d: %s", i+1, nTxs, tx.Hash().Hex())
213
+ txs = append(txs, tx)
214
+ }
215
+
216
+ // Wait for verification
217
+ _, err = operations.ApplyL2Txs(ctx, txs, authL2, clientL2, operations.VerifiedConfirmationLevel)
218
+ require.NoError(t, err)
219
+
220
+ // Assert that he permissionless node is fully synced (through the DAC)
221
+ time.Sleep(30 * time.Second) // Give some time for the permissionless node to get synced
222
+ clientL2Permissionless, err := ethclient.Dial(operations.PermissionlessL2NetworkURL)
223
+ require.NoError(t, err)
224
+ expectedBlock, err := clientL2.BlockByNumber(ctx, nil)
225
+ require.NoError(t, err)
226
+ actualBlock, err := clientL2Permissionless.BlockByNumber(ctx, nil)
227
+ require.NoError(t, err)
228
+ // je, err := expectedBlock.Header().MarshalJSON()
229
+ // require.NoError(t, err)
230
+ // log.Info(string(je))
231
+ // ja, err := actualBlock.Header().MarshalJSON()
232
+ // require.NoError(t, err)
233
+ // log.Info(string(ja))
234
+ // require.Equal(t, string(je), string(ja))
235
+ require.Equal(t, expectedBlock.Root().Hex(), actualBlock.Root().Hex())
236
+ }
237
+
238
+ type member struct {
239
+ addr common.Address
240
+ pk *ecdsa.PrivateKey
241
+ url string
242
+ i int
243
+ }
244
+ type members []member
245
+
246
+ func (s members) Len() int { return len(s) }
247
+ func (s members) Less(i, j int) bool {
248
+ return strings.ToUpper(s[i].addr.Hex()) < strings.ToUpper(s[j].addr.Hex())
249
+ }
250
+ func (s members) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
251
+
252
+ func createKeyStore(pk *ecdsa.PrivateKey, outputDir, password string) error {
253
+ ks := keystore.NewKeyStore(outputDir+"_", keystore.StandardScryptN, keystore.StandardScryptP)
254
+ _, err := ks.ImportECDSA(pk, password)
255
+ if err != nil {
256
+ return err
257
+ }
258
+ fileNameB, err := exec.Command("ls", outputDir+"_/").CombinedOutput()
259
+ fileName := strings.TrimSuffix(string(fileNameB), "\n")
260
+ if err != nil {
261
+ fmt.Println(fileName)
262
+ return err
263
+ }
264
+ out, err := exec.Command("mv", outputDir+"_/"+fileName, outputDir).CombinedOutput()
265
+ if err != nil {
266
+ fmt.Println(string(out))
267
+ return err
268
+ }
269
+ return nil
270
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/debug_calltracer_test.go RENAMED
@@ -104,6 +104,9 @@
104
  {name: "memory", prepare: prepareMemory, createSignedTx: createMemorySignedTx},
105
  {name: "bridge", prepare: prepareBridge, createSignedTx: createBridgeSignedTx},
106
  {name: "deploy create 0", createSignedTx: createDeployCreate0SignedTx},
 
 
 
107
 
108
  // failed transactions
109
  {name: "sc deployment reverted", createSignedTx: createScDeployRevertedSignedTx},
 
104
  {name: "memory", prepare: prepareMemory, createSignedTx: createMemorySignedTx},
105
  {name: "bridge", prepare: prepareBridge, createSignedTx: createBridgeSignedTx},
106
  {name: "deploy create 0", createSignedTx: createDeployCreate0SignedTx},
107
+ {name: "log0 all zeros", prepare: prepareLog0, createSignedTx: createLog0AllZeros},
108
+ {name: "log0 empty", prepare: prepareLog0, createSignedTx: createLog0Empty},
109
+ {name: "log0 short", prepare: prepareLog0, createSignedTx: createLog0Short},
110
 
111
  // failed transactions
112
  {name: "sc deployment reverted", createSignedTx: createScDeployRevertedSignedTx},
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/debug_shared.go RENAMED
@@ -883,3 +884,72 @@
883
  log.Debugf("sending eth transfer: %v", signedTx.Hash().String())
884
  }
885
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
884
  log.Debugf("sending eth transfer: %v", signedTx.Hash().String())
885
  }
886
  }
887
+
888
+ func prepareLog0(t *testing.T, ctx context.Context, auth *bind.TransactOpts, client *ethclient.Client) (map[string]interface{}, error) {
889
+ _, tx, sc, err := Log0.DeployLog0(auth, client)
890
+ require.NoError(t, err)
891
+
892
+ err = operations.WaitTxToBeMined(ctx, client, tx, operations.DefaultTimeoutTxToBeMined)
893
+ require.NoError(t, err)
894
+
895
+ return map[string]interface{}{
896
+ "sc": sc,
897
+ }, nil
898
+ }
899
+
900
+ func createLog0AllZeros(t *testing.T, ctx context.Context, auth *bind.TransactOpts, client *ethclient.Client, customData map[string]interface{}) (*ethTypes.Transaction, error) {
901
+ scInterface := customData["sc"]
902
+ sc := scInterface.(*Log0.Log0)
903
+
904
+ gasPrice, err := client.SuggestGasPrice(ctx)
905
+ require.NoError(t, err)
906
+
907
+ opts := *auth
908
+ opts.NoSend = true
909
+ opts.Value = big.NewInt(0).SetUint64(txValue)
910
+ opts.GasPrice = gasPrice
911
+ opts.GasLimit = fixedTxGasLimit
912
+
913
+ tx, err := sc.OpLog0(&opts)
914
+ require.NoError(t, err)
915
+
916
+ return tx, nil
917
+ }
918
+
919
+ func createLog0Empty(t *testing.T, ctx context.Context, auth *bind.TransactOpts, client *ethclient.Client, customData map[string]interface{}) (*ethTypes.Transaction, error) {
920
+ scInterface := customData["sc"]
921
+ sc := scInterface.(*Log0.Log0)
922
+
923
+ gasPrice, err := client.SuggestGasPrice(ctx)
924
+ require.NoError(t, err)
925
+
926
+ opts := *auth
927
+ opts.NoSend = true
928
+ opts.Value = big.NewInt(0).SetUint64(txValue)
929
+ opts.GasPrice = gasPrice
930
+ opts.GasLimit = fixedTxGasLimit
931
+
932
+ tx, err := sc.OpLog00(&opts)
933
+ require.NoError(t, err)
934
+
935
+ return tx, nil
936
+ }
937
+
938
+ func createLog0Short(t *testing.T, ctx context.Context, auth *bind.TransactOpts, client *ethclient.Client, customData map[string]interface{}) (*ethTypes.Transaction, error) {
939
+ scInterface := customData["sc"]
940
+ sc := scInterface.(*Log0.Log0)
941
+
942
+ gasPrice, err := client.SuggestGasPrice(ctx)
943
+ require.NoError(t, err)
944
+
945
+ opts := *auth
946
+ opts.NoSend = true
947
+ opts.Value = big.NewInt(0).SetUint64(txValue)
948
+ opts.GasPrice = gasPrice
949
+ opts.GasLimit = fixedTxGasLimit
950
+
951
+ tx, err := sc.OpLog01(&opts)
952
+ require.NoError(t, err)
953
+
954
+ return tx, nil
955
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/debug_test.go RENAMED
@@ -318,6 +318,9 @@
318
  {name: "memory", prepare: prepareMemory, createSignedTx: createMemorySignedTx},
319
  {name: "bridge", prepare: prepareBridge, createSignedTx: createBridgeSignedTx},
320
  {name: "deploy create 0", createSignedTx: createDeployCreate0SignedTx},
 
 
 
321
 
322
  // failed transactions
323
  {name: "sc deployment reverted", createSignedTx: createScDeployRevertedSignedTx},
@@ -733,6 +736,58 @@
733
  }
734
  }
735
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
736
  func getTxInResponseDebugTest(t *testing.T, response json.RawMessage, txIndex uint, debugPrefix string) map[string]interface{} {
737
  valueMap := []interface{}{}
738
  err := json.Unmarshal(response, &valueMap)
 
318
  {name: "memory", prepare: prepareMemory, createSignedTx: createMemorySignedTx},
319
  {name: "bridge", prepare: prepareBridge, createSignedTx: createBridgeSignedTx},
320
  {name: "deploy create 0", createSignedTx: createDeployCreate0SignedTx},
321
+ {name: "log0 all zeros", prepare: prepareLog0, createSignedTx: createLog0AllZeros},
322
+ {name: "log0 empty", prepare: prepareLog0, createSignedTx: createLog0Empty},
323
+ {name: "log0 short", prepare: prepareLog0, createSignedTx: createLog0Short},
324
 
325
  // failed transactions
326
  {name: "sc deployment reverted", createSignedTx: createScDeployRevertedSignedTx},
 
736
  }
737
  }
738
 
739
+ func Test_DebugFirstBatch(t *testing.T) {
740
+ if testing.Short() {
741
+ t.Skip()
742
+ }
743
+
744
+ const l2NetworkURL = "http://localhost:8124"
745
+ const l2ExplorerRPCComponentName = "l2-explorer-json-rpc"
746
+
747
+ var err error
748
+ if !dockersArePreLaunchedForDebugTests {
749
+ err = operations.Teardown()
750
+ require.NoError(t, err)
751
+
752
+ defer func() {
753
+ require.NoError(t, operations.Teardown())
754
+ require.NoError(t, operations.StopComponent(l2ExplorerRPCComponentName))
755
+ }()
756
+ }
757
+
758
+ ctx := context.Background()
759
+ opsCfg := operations.GetDefaultOperationsConfig()
760
+ if !dockersArePreLaunchedForDebugTests {
761
+ opsMan, err := operations.NewManager(ctx, opsCfg)
762
+ require.NoError(t, err)
763
+ err = opsMan.Setup()
764
+ require.NoError(t, err)
765
+
766
+ err = operations.StartComponent(l2ExplorerRPCComponentName, func() (bool, error) { return operations.NodeUpCondition(l2NetworkURL) })
767
+ require.NoError(t, err)
768
+ } else {
769
+ log.Info("Using pre-launched dockers: no reset Database")
770
+ }
771
+
772
+ debugOptions := map[string]interface{}{
773
+ "tracer": "callTracer",
774
+ "tracerConfig": map[string]interface{}{
775
+ "onlyTopCall": false,
776
+ "withLog": true,
777
+ },
778
+ }
779
+
780
+ response, err := client.JSONRPCCall(l2NetworkURL, "debug_traceBlockByNumber", "0x1", debugOptions)
781
+ require.NoError(t, err)
782
+ require.Nil(t, response.Error)
783
+ require.NotNil(t, response.Result)
784
+
785
+ response, err = client.JSONRPCCall(l2NetworkURL, "debug_traceBlockByNumber", "0x1")
786
+ require.NoError(t, err)
787
+ require.Nil(t, response.Error)
788
+ require.NotNil(t, response.Result)
789
+ }
790
+
791
  func getTxInResponseDebugTest(t *testing.T, response json.RawMessage, txIndex uint, debugPrefix string) map[string]interface{} {
792
  valueMap := []interface{}{}
793
  err := json.Unmarshal(response, &valueMap)
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_test.go RENAMED
@@ -196,7 +196,7 @@
196
  require.NoError(t, err)
197
  genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr)
198
  require.NoError(t, err)
199
- require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6))
200
  err = opsman.Setup()
201
  require.NoError(t, err)
202
  time.Sleep(5 * time.Second)
 
196
  require.NoError(t, err)
197
  genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr)
198
  require.NoError(t, err)
199
+ require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6))
200
  err = opsman.Setup()
201
  require.NoError(t, err)
202
  time.Sleep(5 * time.Second)
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_vector_shared.go RENAMED
@@ -63,8 +63,8 @@
63
  log.Info("# Setting Genesis #")
64
  log.Info("###################")
65
  genesisActions := vectors.GenerateGenesisActions(testCase.Genesis)
66
- require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.BlockNumber, genesisActions))
67
- require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6))
68
  actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil)
69
  require.NoError(t, err)
70
  require.NoError(t, opsman.Setup())
 
63
  log.Info("# Setting Genesis #")
64
  log.Info("###################")
65
  genesisActions := vectors.GenerateGenesisActions(testCase.Genesis)
66
+ require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.RollupBlockNumber, genesisActions))
67
+ require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6))
68
  actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil)
69
  require.NoError(t, err)
70
  require.NoError(t, opsman.Setup())
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/state_test.go RENAMED
@@ -59,7 +59,7 @@
59
  for _, gacc := range testCase.GenesisAccounts {
60
  genesisAccounts[gacc.Address] = gacc.Balance.Int
61
  }
62
- require.NoError(t, opsman.SetGenesisAccountsBalance(genesisConfig.Genesis.BlockNumber, genesisAccounts))
63
 
64
  // Check initial root
65
  require.NoError(t, opsman.CheckVirtualRoot(testCase.ExpectedOldRoot))
 
59
  for _, gacc := range testCase.GenesisAccounts {
60
  genesisAccounts[gacc.Address] = gacc.Balance.Int
61
  }
62
+ require.NoError(t, opsman.SetGenesisAccountsBalance(genesisConfig.Genesis.RollupBlockNumber, genesisAccounts))
63
 
64
  // Check initial root
65
  require.NoError(t, opsman.CheckVirtualRoot(testCase.ExpectedOldRoot))
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/Makefile RENAMED
@@ -26,6 +26,7 @@
26
  DOCKERCOMPOSEZKPROVER := zkevm-prover
27
  DOCKERCOMPOSEPERMISSIONLESSDB := zkevm-permissionless-db
28
  DOCKERCOMPOSEPERMISSIONLESSNODE := zkevm-permissionless-node
 
29
  DOCKERCOMPOSEPERMISSIONLESSZKPROVER := zkevm-permissionless-prover
30
  DOCKERCOMPOSENODEAPPROVE := zkevm-approve
31
  DOCKERCOMPOSENODEAPPROVEV1TOV2 := zkevm-approve-v1tov2
@@ -62,6 +63,7 @@
62
 
63
  RUNPERMISSIONLESSDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSDB)
64
  RUNPERMISSIONLESSNODE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODE)
 
65
  RUNPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER)
66
 
67
  RUNAPPROVE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSENODEAPPROVE)
@@ -101,6 +103,7 @@
101
 
102
  STOPPERMISSIONLESSDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSDB)
103
  STOPPERMISSIONLESSNODE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODE)
 
104
  STOPPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER)
105
 
106
  STOPAPPROVE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSENODEAPPROVE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSENODEAPPROVE)
@@ -110,6 +113,9 @@
110
 
111
  STOP := $(DOCKERCOMPOSE) down --remove-orphans
112
 
 
 
 
113
  .PHONY: test-full-non-e2e
114
  test-full-non-e2e: stop ## Runs non-e2e tests checking race conditions
115
  $(RUNSTATEDB)
@@ -248,6 +254,17 @@
248
  docker logs $(DOCKERCOMPOSEZKPROVER)
249
  trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -failfast -race -v -p 1 -timeout 2000s ../ci/e2e-group11/...
250
 
 
 
 
 
 
 
 
 
 
 
 
251
  .PHONY: benchmark-sequencer-eth-transfers
252
  benchmark-sequencer-eth-transfers: stop
253
  $(RUNL1NETWORK)
@@ -685,10 +702,12 @@
685
  .PHONY: generate-mocks-synchronizer
686
  generate-mocks-synchronizer: ## Generates mocks for synchronizer , using mockery tool
687
  ## mocks for synchronizer
688
- #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthermanInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS}
689
- #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=StateMock --filename=mock_state.go ${COMMON_MOCKERY_PARAMS}
690
- #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethTxManager --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS}
691
- #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS}
 
 
692
  for i in l1RollupProducerInterface l1RollupConsumerInterface worker synchronizerProcessBlockRangeInterface workersInterface L1ParallelEthermanInterface; do \
693
  camelcase=$$(echo $$i | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]') ; \
694
  echo $$camelcase ; \
@@ -709,7 +728,7 @@
709
 
710
 
711
 
712
- export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../synchronizer/mocks --structname=DbTxMock --filename=mock_dbtx.go
713
 
714
  .PHONY: generate-mocks-etherman
715
  generate-mocks-etherman: ## Generates mocks for etherman , using mockery tool
@@ -722,6 +741,8 @@
722
 
723
  export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go
724
  export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go
 
 
725
 
726
  .PHONY: generate-mocks-aggregator
727
  generate-mocks-aggregator: ## Generates mocks for aggregator , using mockery tool
@@ -745,6 +766,27 @@
745
  run-benchmarks: run-db ## Runs benchmars
746
  go test -bench=. ./state/tree
747
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748
  .PHONY: compile-scs
749
  compile-scs: ## Compiles smart contracts, configuration in test/contracts/index.yaml
750
  go run ./scripts/cmd... compilesc --input ./contracts
 
26
  DOCKERCOMPOSEZKPROVER := zkevm-prover
27
  DOCKERCOMPOSEPERMISSIONLESSDB := zkevm-permissionless-db
28
  DOCKERCOMPOSEPERMISSIONLESSNODE := zkevm-permissionless-node
29
+ DOCKERCOMPOSEPERMISSIONLESSNODEDAC := zkevm-node-forced-DAC
30
  DOCKERCOMPOSEPERMISSIONLESSZKPROVER := zkevm-permissionless-prover
31
  DOCKERCOMPOSENODEAPPROVE := zkevm-approve
32
  DOCKERCOMPOSENODEAPPROVEV1TOV2 := zkevm-approve-v1tov2
 
63
 
64
  RUNPERMISSIONLESSDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSDB)
65
  RUNPERMISSIONLESSNODE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODE)
66
+ RUNPERMISSIONLESSNODEDAC := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODEDAC)
67
  RUNPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER)
68
 
69
  RUNAPPROVE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSENODEAPPROVE)
 
103
 
104
  STOPPERMISSIONLESSDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSDB)
105
  STOPPERMISSIONLESSNODE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODE)
106
+ STOPPERMISSIONLESSNODEDAC := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODEDAC) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODEDAC)
107
  STOPPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER)
108
 
109
  STOPAPPROVE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSENODEAPPROVE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSENODEAPPROVE)
 
113
 
114
  STOP := $(DOCKERCOMPOSE) down --remove-orphans
115
 
116
+ RUNDACDB := docker-compose up -d zkevm-data-node-db
117
+ STOPDACDB := docker-compose stop zkevm-data-node-db && docker-compose rm -f zkevm-data-node-db
118
+
119
  .PHONY: test-full-non-e2e
120
  test-full-non-e2e: stop ## Runs non-e2e tests checking race conditions
121
  $(RUNSTATEDB)
 
254
  docker logs $(DOCKERCOMPOSEZKPROVER)
255
  trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -failfast -race -v -p 1 -timeout 2000s ../ci/e2e-group11/...
256
 
257
+ .PHONY: test-e2e-group-cdk-validium-1
258
+ test-e2e-group-cdk-validium-1: stop ## Runs cdk-validium-1 e2e tests checking race conditions
259
+ $(RUNSTATEDB)
260
+ $(RUNPOOLDB)
261
+ $(RUNEVENTDB)
262
+ sleep 5
263
+ $(RUNZKPROVER)
264
+ docker ps -a
265
+ docker logs $(DOCKERCOMPOSEZKPROVER)
266
+ trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -race -v -p 1 -timeout 2000s ../ci/e2e-group-cdk-validium-1/...
267
+
268
  .PHONY: benchmark-sequencer-eth-transfers
269
  benchmark-sequencer-eth-transfers: stop
270
  $(RUNL1NETWORK)
 
702
  .PHONY: generate-mocks-synchronizer
703
  generate-mocks-synchronizer: ## Generates mocks for synchronizer , using mockery tool
704
  ## mocks for synchronizer
705
+ export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthermanFullInterface --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS}
706
+ export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=StateFullInterface --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=StateMock --filename=mock_state.go ${COMMON_MOCKERY_PARAMS}
707
+ export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=ethTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS}
708
+ export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=PoolInterface --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS}
709
+ export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Factory --srcpkg=github.com/0xPolygon/cdk-data-availability/client --output=../synchronizer --outpkg=synchronizer --structname=dataCommitteeClientFactoryMock --filename=mock_datacommitteeclientfactory.go ${COMMON_MOCKERY_PARAMS}
710
+ export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Client --srcpkg=github.com/0xPolygon/cdk-data-availability/client --output=../synchronizer --outpkg=synchronizer --structname=dataCommitteeClientMock --filename=mock_datacommitteeclient.go ${COMMON_MOCKERY_PARAMS}
711
  for i in l1RollupProducerInterface l1RollupConsumerInterface worker synchronizerProcessBlockRangeInterface workersInterface L1ParallelEthermanInterface; do \
712
  camelcase=$$(echo $$i | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]') ; \
713
  echo $$camelcase ; \
 
728
 
729
 
730
 
731
+ export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../synchronizer/mocks --structname=DbTxMock --filename=mock_dbtx.go ${COMMON_MOCKERY_PARAMS}
732
 
733
  .PHONY: generate-mocks-etherman
734
  generate-mocks-etherman: ## Generates mocks for etherman , using mockery tool
 
741
 
742
  export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go
743
  export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go
744
+
745
+ export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=dataAvailabilityProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=daMock --filename=mock_da.go
746
 
747
  .PHONY: generate-mocks-aggregator
748
  generate-mocks-aggregator: ## Generates mocks for aggregator , using mockery tool
 
766
  run-benchmarks: run-db ## Runs benchmars
767
  go test -bench=. ./state/tree
768
 
769
+ .PHONY: run-dac-db
770
+ run-dac-db: ## Suns the DAC DB
771
+ $(RUNDACDB)
772
+
773
+ .PHONY: stop-dac-db
774
+ stop-dac-db: ## Stops the DAC DB
775
+ $(STOPDACDB)
776
+
777
+ .PHONY: run-permissionless-dac
778
+ run-permissionless-dac: ## Runs a permissionless node that is forced to sync through DAC
779
+ $(RUNPERMISSIONLESSDB)
780
+ sleep 1
781
+ $(RUNPERMISSIONLESSZKPROVER)
782
+ $(RUNPERMISSIONLESSNODEDAC)
783
+
784
+ .PHONY: stop-permissionless-dac
785
+ stop-permissionless-dac: ## Stops the permissionless node that is forced to sync through DAC
786
+ $(STOPPERMISSIONLESSNODEDAC)
787
+ $(STOPPERMISSIONLESSZKPROVER)
788
+ $(STOPPERMISSIONLESSDB)
789
+
790
  .PHONY: compile-scs
791
  compile-scs: ## Compiles smart contracts, configuration in test/contracts/index.yaml
792
  go run ./scripts/cmd... compilesc --input ./contracts
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/operations/manager.go RENAMED
@@ -46,6 +46,7 @@
46
  DefaultL1ZkEVMSmartContract = "0x8dAF17A20c9DBA35f005b6324F493785D239719d"
47
  DefaultL1RollupManagerSmartContract = "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
48
  DefaultL1PolSmartContract = "0x5FbDB2315678afecb367f032d93F642f64180aa3"
 
49
  DefaultL1NetworkURL = "http://localhost:8545"
50
  DefaultL1NetworkWebSocketURL = "ws://localhost:8546"
51
  DefaultL1ChainID uint64 = 1337
@@ -263,7 +264,6 @@
263
  if confirmationLevel == PoolConfirmationLevel {
264
  return nil, nil
265
  }
266
-
267
  l2BlockNumbers := make([]*big.Int, 0, len(sentTxs))
268
  for _, tx := range sentTxs {
269
  // check transaction nonce against transaction reported L2 block number
@@ -662,3 +662,23 @@
662
  panic(err)
663
  }
664
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  DefaultL1ZkEVMSmartContract = "0x8dAF17A20c9DBA35f005b6324F493785D239719d"
47
  DefaultL1RollupManagerSmartContract = "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
48
  DefaultL1PolSmartContract = "0x5FbDB2315678afecb367f032d93F642f64180aa3"
49
+ DefaultL1DataCommitteeContract = "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE"
50
  DefaultL1NetworkURL = "http://localhost:8545"
51
  DefaultL1NetworkWebSocketURL = "ws://localhost:8546"
52
  DefaultL1ChainID uint64 = 1337
 
264
  if confirmationLevel == PoolConfirmationLevel {
265
  return nil, nil
266
  }
 
267
  l2BlockNumbers := make([]*big.Int, 0, len(sentTxs))
268
  for _, tx := range sentTxs {
269
  // check transaction nonce against transaction reported L2 block number
 
662
  panic(err)
663
  }
664
  }
665
+
666
+ // StartDACDB starts the data availability node DB
667
+ func (m *Manager) StartDACDB() error {
668
+ return StartComponent("dac-db", func() (bool, error) { return true, nil })
669
+ }
670
+
671
+ // StopDACDB stops the data availability node DB
672
+ func (m *Manager) StopDACDB() error {
673
+ return StopComponent("dac-db")
674
+ }
675
+
676
+ // StartPermissionlessNodeForcedToSYncThroughDAC starts a permissionless node that is froced to sync through the DAC
677
+ func (m *Manager) StartPermissionlessNodeForcedToSYncThroughDAC() error {
678
+ return StartComponent("permissionless-dac", func() (bool, error) { return true, nil })
679
+ }
680
+
681
+ // StopPermissionlessNodeForcedToSYncThroughDAC stops the permissionless node that is froced to sync through the DAC
682
+ func (m *Manager) StopPermissionlessNodeForcedToSYncThroughDAC() error {
683
+ return StopComponent("permissionless-dac")
684
+ }
{/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/batchsender/main.go RENAMED
@@ -111,7 +111,7 @@
111
  return err
112
  }
113
 
114
- ethMan, err := etherman.NewClient(cfg.Etherman, cfg.NetworkConfig.L1Config)
115
  if err != nil {
116
  return err
117
  }
@@ -183,7 +183,7 @@
183
  // send to L1
184
  firstSequence := seqs[0]
185
  lastSequence := seqs[len(seqs)-1]
186
- to, data, err := ethMan.BuildSequenceBatchesTxData(auth.From, seqs, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber, auth.From)
187
  if err != nil {
188
  return err
189
  }
 
111
  return err
112
  }
113
 
114
+ ethMan, err := etherman.NewClient(cfg.Etherman, cfg.NetworkConfig.L1Config, nil)
115
  if err != nil {
116
  return err
117
  }
 
183
  // send to L1
184
  firstSequence := seqs[0]
185
  lastSequence := seqs[len(seqs)-1]
186
+ to, data, err := ethMan.BuildSequenceBatchesTxData(auth.From, seqs, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber, auth.From, nil)
187
  if err != nil {
188
  return err
189
  }
{/home/stefan/go/src/Polygon/zkevm-node → .}/tools/state/main.go RENAMED
@@ -32,7 +32,7 @@
32
  networkFlag = cli.StringFlag{
33
  Name: config.FlagNetwork,
34
  Aliases: []string{"net"},
35
- Usage: "Load default network configuration. Supported values: [`mainnet`, `testnet`, `cardona`, `custom`]",
36
  Required: false,
37
  }
38
  customNetworkFlag = cli.StringFlag{
 
32
  networkFlag = cli.StringFlag{
33
  Name: config.FlagNetwork,
34
  Aliases: []string{"net"},
35
+ Usage: "Load default network configuration. Supported values: [`custom`]",
36
  Required: false,
37
  }
38
  customNetworkFlag = cli.StringFlag{
{/home/stefan/go/src/Polygon/zkevm-node → .}/tools/state/reprocess_cmd.go RENAMED
@@ -77,7 +77,7 @@
77
  }
78
 
79
  func newEtherman(c config.Config) (*etherman.Client, error) {
80
- etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config)
81
  if err != nil {
82
  return nil, err
83
  }
 
77
  }
78
 
79
  func newEtherman(c config.Config) (*etherman.Client, error) {
80
+ etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil)
81
  if err != nil {
82
  return nil, err
83
  }